MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / parseArgs

Function parseArgs

compatible-shell/src/cli.mjs:286–322  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

284}
285
286function parseArgs(argv) {
287 const options = {
288 promptParts: [],
289 }
290
291 for (let index = 0; index < argv.length; index += 1) {
292 const arg = argv[index]
293 if (arg === '--help' || arg === '-h') {
294 options.help = true
295 continue
296 }
297 if (arg === '--cwd') {
298 options.cwd = argv[index + 1]
299 index += 1
300 continue
301 }
302 if (arg === '--max-tool-rounds') {
303 options.maxToolRounds = argv[index + 1]
304 index += 1
305 continue
306 }
307 if (arg === '--auto-approve-shell') {
308 options.autoApproveShell = true
309 continue
310 }
311 if (arg === '--prompt') {
312 options.promptParts.push(argv[index + 1] || '')
313 index += 1
314 continue
315 }
316
317 options.promptParts.push(arg)
318 }
319
320 options.prompt = options.promptParts.join(' ').trim()
321 return options
322}
323
324function parsePositiveInt(value, fallback) {
325 const parsed = Number.parseInt(value || '', 10)

Callers 1

mainFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected