-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathcommand.tsx
More file actions
36 lines (30 loc) · 1.09 KB
/
command.tsx
File metadata and controls
36 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { renderTUI } from '../../tui';
import { COMMAND_DESCRIPTIONS } from '../../tui/copy';
import { requireProject, requireTTY } from '../../tui/guards';
import type { Command } from '@commander-js/extra-typings';
export function registerAdd(program: Command): Command {
const addCmd = program
.command('add')
.description(COMMAND_DESCRIPTIONS.add)
.showHelpAfterError()
.showSuggestionAfterError();
// Catch-all argument for invalid subcommands - Commander matches subcommands first
addCmd.argument('[subcommand]').action(async (subcommand: string | undefined, _options, cmd) => {
if (subcommand) {
console.error(`error: '${subcommand}' is not a valid subcommand.`);
cmd.outputHelp();
process.exit(1);
}
requireProject();
requireTTY();
await renderTUI({
initialRoute: { name: 'add' },
enterAltScreen: false,
actionOnBack: 'exit',
isInteractive: false,
});
});
// Subcommands (agent, memory, credential, gateway, gateway-target) are registered
// via primitive.registerCommands() in cli.ts
return addCmd;
}