MCPcopy Create free account
hub / github.com/apache/maka / parseProjectCommand

Function parseProjectCommand

packages/cli/src/runtime-host-cli.ts:86–117  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

84}
85
86function parseProjectCommand(argv: string[]): RuntimeHostCliCommand {
87 const action = argv[0];
88 if (action !== 'list' && action !== 'add') {
89 return error(
90 action
91 ? `Unexpected runtime-host project command: ${action}`
92 : 'runtime-host project requires the list or add command',
93 );
94 }
95 let rootPath: string | undefined;
96 let path: string | undefined;
97 for (let index = 1; index < argv.length; index += 1) {
98 const argument = argv[index];
99 if (argument === '--root') {
100 const parsed = optionValue(argv, index, argument);
101 if (typeof parsed !== 'string') return parsed;
102 rootPath = parsed;
103 index += 1;
104 continue;
105 }
106 if (action === 'add' && path === undefined) {
107 path = argument;
108 continue;
109 }
110 return error(`Unexpected argument: ${argument ?? ''}`);
111 }
112 if (action === 'list') {
113 return { kind: 'runtime-host-project-list', ...(rootPath ? { rootPath } : {}) };
114 }
115 if (!path) return error('runtime-host project add requires a path');
116 return { kind: 'runtime-host-project-add', path, ...(rootPath ? { rootPath } : {}) };
117}
118
119function parseProfileCommand(argv: string[]): RuntimeHostCliCommand {
120 const action = argv[0];

Callers 1

parseRuntimeHostCommandFunction · 0.85

Calls 2

errorFunction · 0.70
optionValueFunction · 0.70

Tested by

no test coverage detected