forked from MiniMax-AI/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.ts
More file actions
57 lines (52 loc) · 1.89 KB
/
Copy pathcommand.ts
File metadata and controls
57 lines (52 loc) · 1.89 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import type { Config } from './config/schema';
import type { GlobalFlags } from './types/flags';
export interface OptionDef {
flag: string;
description: string;
type?: 'string' | 'number' | 'boolean' | 'array';
required?: boolean;
}
export interface Command {
name: string;
description: string;
usage?: string;
options?: OptionDef[];
examples?: string[];
apiDocs?: string;
execute(config: Config, flags: GlobalFlags): Promise<void>;
}
export interface CommandSpec {
name: string;
description: string;
usage?: string;
options?: OptionDef[];
examples?: string[];
apiDocs?: string;
run(config: Config, flags: GlobalFlags): Promise<void>;
}
export function defineCommand(spec: CommandSpec): Command {
return {
name: spec.name,
description: spec.description,
usage: spec.usage,
options: spec.options,
examples: spec.examples,
apiDocs: spec.apiDocs,
execute: spec.run,
};
}
/** Global flags shared by all commands — drives the parser's type resolution. */
export const GLOBAL_OPTIONS: OptionDef[] = [
{ flag: '--api-key <key>', description: 'API key' },
{ flag: '--region <region>', description: 'API region: global, cn' },
{ flag: '--base-url <url>', description: 'API base URL' },
{ flag: '--output <format>', description: 'Output format: text, json' },
{ flag: '--timeout <seconds>', description: 'Request timeout', type: 'number' },
{ flag: '--quiet', description: 'Suppress non-essential output' },
{ flag: '--verbose', description: 'Print HTTP request/response details' },
{ flag: '--no-color', description: 'Disable ANSI colors' },
{ flag: '--dry-run', description: 'Dry run mode' },
{ flag: '--non-interactive', description: 'Disable interactive prompts' },
{ flag: '--help', description: 'Show help' },
{ flag: '--version', description: 'Print version' },
];