MCPcopy Create free account
hub / github.com/AICoderTudou/claude-code-tudou / parseArgs

Function parseArgs

src/localRecoveryCli.ts:39–106  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

37}
38
39function parseArgs(argv: string[]) {
40 let print = false
41 let model = process.env.ANTHROPIC_MODEL
42 let systemPrompt: string | undefined
43 let appendSystemPrompt: string | undefined
44 let outputFormat: OutputFormat = 'text'
45 const positional: string[] = []
46
47 for (let i = 0; i < argv.length; i++) {
48 const arg = argv[i]
49 if (!arg) continue
50
51 if (arg === '-h' || arg === '--help') {
52 return { command: 'help' as const }
53 }
54 if (arg === '-v' || arg === '--version' || arg === '-V') {
55 return { command: 'version' as const }
56 }
57 if (arg === '-p' || arg === '--print') {
58 print = true
59 continue
60 }
61 if (arg === '--bare') {
62 continue
63 }
64 if (arg === '--dangerously-skip-permissions') {
65 continue
66 }
67 if (arg === '--model') {
68 model = argv[++i]
69 continue
70 }
71 if (arg === '--system-prompt') {
72 systemPrompt = argv[++i]
73 continue
74 }
75 if (arg === '--system-prompt-file') {
76 const file = argv[++i]
77 systemPrompt = readFileSync(file!, 'utf8')
78 continue
79 }
80 if (arg === '--append-system-prompt') {
81 appendSystemPrompt = argv[++i]
82 continue
83 }
84 if (arg === '--output-format') {
85 const value = argv[++i]
86 if (value === 'json' || value === 'text') {
87 outputFormat = value
88 }
89 continue
90 }
91 if (arg.startsWith('-')) {
92 continue
93 }
94 positional.push(arg)
95 }
96

Callers 1

runFunction · 0.70

Calls 1

readFileSyncFunction · 0.90

Tested by

no test coverage detected