MCPcopy
hub / github.com/MiniMax-AI/cli / scanCommandPath

Function scanCommandPath

src/args.ts:46–73  ·  view source on GitHub ↗
(argv: string[], globalOptions: OptionDef[] = [])

Source from the content-addressed store, hash-verified

44 * correctly produces ['text', 'chat'] instead of ['json', 'text', 'chat'].
45 */
46export function scanCommandPath(argv: string[], globalOptions: OptionDef[] = []): string[] {
47 const globalSchema = buildSchema(globalOptions);
48 const path: string[] = [];
49 let i = 0;
50 while (i < argv.length) {
51 const arg = argv[i]!;
52 if (arg === '--') break;
53
54 if (arg.startsWith('--')) {
55 const eqIdx = arg.indexOf('=');
56 const key = eqIdx !== -1 ? arg.slice(2, eqIdx) : arg.slice(2);
57 const camelKey = kebabToCamel(key);
58
59 if (!globalSchema.booleans.has(camelKey) && eqIdx === -1) {
60 i += 2;
61 } else {
62 i += 1;
63 }
64 continue;
65 }
66
67 if (arg.startsWith('-')) { i++; continue; }
68
69 path.push(arg);
70 i++;
71 }
72 return path;
73}
74
75/**
76 * Full flag parse. Types are derived entirely from the provided OptionDef schema:

Callers 1

mainFunction · 0.90

Calls 2

buildSchemaFunction · 0.85
kebabToCamelFunction · 0.85

Tested by

no test coverage detected