-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcommand.tsx
More file actions
40 lines (34 loc) · 1.15 KB
/
command.tsx
File metadata and controls
40 lines (34 loc) · 1.15 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
37
38
39
40
import { COMMAND_DESCRIPTIONS } from '../../tui/copy';
import { requireProject } from '../../tui/guards';
import { AddFlow } from '../../tui/screens/add/AddFlow';
import type { Command } from '@commander-js/extra-typings';
import { render } from 'ink';
import React from 'react';
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((subcommand: string | undefined, _options, cmd) => {
if (subcommand) {
console.error(`error: '${subcommand}' is not a valid subcommand.`);
cmd.outputHelp();
process.exit(1);
}
requireProject();
const { clear, unmount } = render(
<AddFlow
isInteractive={false}
onExit={() => {
clear();
unmount();
}}
/>
);
});
// Subcommands (agent, memory, credential, gateway, gateway-target) are registered
// via primitive.registerCommands() in cli.ts
return addCmd;
}