MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / takeFlagValue

Function takeFlagValue

src/index.tsx:83–93  ·  view source on GitHub ↗

Pop `flag ` (accepting -flag and --flag) out of args; returns the value.

(args: string[], name: string)

Source from the content-addressed store, hash-verified

81
82/** Pop `flag <value>` (accepting -flag and --flag) out of args; returns the value. */
83function takeFlagValue(args: string[], name: string): string | undefined {
84 const index = args.findIndex((a) => a === `--${name}` || a === `-${name}`)
85 if (index === -1) return undefined
86 const value = args[index + 1]
87 if (!value || value.startsWith("-")) {
88 console.error(`Missing value after --${name}`)
89 process.exit(1)
90 }
91 args.splice(index, 2)
92 return value
93}
94
95/**
96 * Pop the `-s` / `--system-prompt` flag (and its value) out of `args`.

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected