-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.ts
More file actions
56 lines (51 loc) · 1.87 KB
/
Copy pathcommand.ts
File metadata and controls
56 lines (51 loc) · 1.87 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
export interface OptionDef {
flag: string;
description: string;
type?: 'string' | 'number' | 'boolean' | 'array';
required?: boolean;
}
export interface CliConfig {
region: 'global' | 'dev';
apiUrl: string;
serverLambdaUrl: string;
environment: string;
output: 'text' | 'json';
timeout: number;
verbose: boolean;
quiet: boolean;
noColor: boolean;
dryRun: boolean;
nonInteractive: boolean;
apiKey?: string;
}
export interface CommandSpec {
name: string;
description: string;
usage?: string;
options?: OptionDef[];
examples?: string[];
run(config: CliConfig, flags: Record<string, unknown>): Promise<void>;
}
export interface Command extends CommandSpec {
execute(config: CliConfig, flags: Record<string, unknown>): Promise<void>;
}
export function defineCommand(spec: CommandSpec): Command {
return {
...spec,
execute: spec.run,
};
}
export const GLOBAL_OPTIONS: OptionDef[] = [
{ flag: '--api-key <key>', description: 'ForLoop API key' },
{ flag: '--api-url <url>', description: 'API base URL (overrides config)' },
{ flag: '--base-url <url>', description: 'Alias for --api-url' },
{ flag: '--output <format>', description: 'Output format: text (default), json' },
{ flag: '--timeout <seconds>', description: 'Request timeout (default: 60)', 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: 'Show what would happen without executing' },
{ flag: '--non-interactive', description: 'Disable interactive prompts (CI mode)' },
{ flag: '--help', description: 'Show help' },
{ flag: '--version', description: 'Print version' },
];