MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / runCommand

Function runCommand

cli/src/cli/run.ts:32–59  ·  view source on GitHub ↗
(
    commands: Command[],
    argv: string[],
    initOptions: InitConfig,
    session?: CliSession,
)

Source from the content-addressed store, hash-verified

30 }
31}
32
33export async function runCommand(
34 commands: Command[],
35 argv: string[],
36 initOptions: InitConfig,
37 session?: CliSession,
38): Promise<void> {
39 const result = await parseCliInvocation(commands, argv, initOptions);
40 if (!result) {
41 return;
42 }
43 const { command, options, args } = result;
44
45 if (options['help']) {
46 printCommandUsage(command);
47 return;
48 }
49
50 const oneOffSession = !session;
51 session = session ?? (await init({ ...initOptions, enableConsoleLog: !!options.verbose }));
52 verifyAuthentication(command, session);
53 try {
54 await command.action({
55 ...session,
56 args,
57 options,
58 });
59 } finally {
60 if (oneOffSession) {
61 await session.dispose();
62 }

Callers 2

startReplFunction · 0.90
runSingleInvocationFunction · 0.85

Calls 6

printCommandUsageFunction · 0.90
initFunction · 0.90
parseCliInvocationFunction · 0.85
verifyAuthenticationFunction · 0.85
disposeMethod · 0.65
actionMethod · 0.45

Tested by

no test coverage detected