MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / parseCliArgs

Function parseCliArgs

lib/cli.js:42–110  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

40]);
41
42function parseCliArgs(argv) {
43 const rawArgs = argv.slice(2);
44 let cwd = null;
45 const claudeArgs = [];
46 const blocked = [];
47 let token = null;
48 let noAuth = false;
49
50 let i = 0;
51 while (i < rawArgs.length) {
52 const arg = rawArgs[i];
53
54 if (arg === '--') {
55 claudeArgs.push(...rawArgs.slice(i + 1));
56 break;
57 }
58
59 if (!arg.startsWith('-')) {
60 if (!cwd) {
61 cwd = arg;
62 } else {
63 claudeArgs.push(arg);
64 }
65 i++;
66 continue;
67 }
68
69 const eqIdx = arg.indexOf('=');
70 const flagName = eqIdx > 0 ? arg.substring(0, eqIdx) : arg;
71
72 if (flagName === '--token') {
73 if (eqIdx > 0) {
74 token = arg.substring(eqIdx + 1);
75 } else if (i + 1 < rawArgs.length && !rawArgs[i + 1].startsWith('-')) {
76 i++;
77 token = rawArgs[i];
78 } else {
79 token = '';
80 }
81 i++;
82 continue;
83 }
84 if (flagName === '--no-auth') {
85 noAuth = true;
86 i++;
87 continue;
88 }
89
90 if (BLOCKED_FLAGS.has(flagName)) {
91 blocked.push(flagName);
92 if (eqIdx > 0) {
93 // --flag=value, already consumed
94 } else if (FLAGS_WITH_VALUE.has(flagName) && i + 1 < rawArgs.length) {
95 i++;
96 }
97 i++;
98 continue;
99 }

Callers 2

initConfigFunction · 0.85
test-modules.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected