Add source files: main entry, types, and configuration
This commit is contained in:
68
src/types/spec.ts
Normal file
68
src/types/spec.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
export interface CLISpec {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
description: string;
|
||||||
|
author?: string;
|
||||||
|
license?: string;
|
||||||
|
homepage?: string;
|
||||||
|
bin?: string;
|
||||||
|
globalOptions?: Option[];
|
||||||
|
commands: Command[];
|
||||||
|
examples?: Example[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Option {
|
||||||
|
name: string;
|
||||||
|
short?: string;
|
||||||
|
description: string;
|
||||||
|
type: 'string' | 'number' | 'boolean' | 'array';
|
||||||
|
required?: boolean;
|
||||||
|
default?: string | number | boolean | string[];
|
||||||
|
choices?: (string | number)[];
|
||||||
|
implies?: string[];
|
||||||
|
conflicts?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Command {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
aliases?: string[];
|
||||||
|
options?: Option[];
|
||||||
|
arguments?: Argument[];
|
||||||
|
subcommands?: Command[];
|
||||||
|
examples?: Example[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Argument {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
required?: boolean;
|
||||||
|
variadic?: boolean;
|
||||||
|
choices?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Example {
|
||||||
|
description: string;
|
||||||
|
command: string;
|
||||||
|
output?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LanguageTarget = 'python' | 'go' | 'rust' | 'node-commander' | 'node-yargs';
|
||||||
|
|
||||||
|
export type ShellType = 'bash' | 'zsh' | 'fish';
|
||||||
|
|
||||||
|
export interface GeneratorOptions {
|
||||||
|
language: LanguageTarget;
|
||||||
|
outputDir?: string;
|
||||||
|
packageName?: string;
|
||||||
|
author?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TemplateContext {
|
||||||
|
spec: CLISpec;
|
||||||
|
command?: Command;
|
||||||
|
options?: Option[];
|
||||||
|
arguments?: Argument[];
|
||||||
|
isSubcommand?: boolean;
|
||||||
|
indent?: string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user