MCPcopy Create free account
hub / github.com/CaviraOSS/OpenReason / parse_args

Function parse_args

src/cli/index.ts:39–97  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

37}
38
39const parse_args = (argv: string[]): { options: cli_options; query: string } => {
40 const options: cli_options = {}
41 const queryParts: string[] = []
42 let i = 0
43 while (i < argv.length) {
44 const token = argv[i]
45 if (!token.startsWith("-")) {
46 queryParts.push(...argv.slice(i))
47 break
48 }
49
50 const next = () => argv[++i]
51 switch (token) {
52 case "--help":
53 case "-h":
54 options.help = true
55 i += 1
56 break
57 case "--env":
58 options.envFile = next()
59 i += 1
60 break
61 case "--provider":
62 options.provider = next() as provider_name
63 i += 1
64 break
65 case "--api-key":
66 options.apiKey = next()
67 i += 1
68 break
69 case "--model":
70 options.model = next()
71 i += 1
72 break
73 case "--simple-model":
74 options.simpleModel = next()
75 i += 1
76 break
77 case "--complex-model":
78 options.complexModel = next()
79 i += 1
80 break
81 case "--memory":
82 options.memory = parse_boolean(next())
83 i += 1
84 break
85 case "--memory-path":
86 options.memoryPath = next()
87 i += 1
88 break
89 default:
90 console.error(`Unknown option: ${token}`)
91 console.log(HELP_TEXT)
92 process.exit(1)
93 }
94 }
95
96 return { options, query: queryParts.join(" ").trim() }

Callers 1

mainFunction · 0.85

Calls 2

nextFunction · 0.85
parse_booleanFunction · 0.85

Tested by

no test coverage detected