2017-12-20 21:46:01 +00:00
|
|
|
declare module 'capitano' {
|
|
|
|
export function parse(argv: string[]): Cli;
|
|
|
|
|
|
|
|
export interface Cli {
|
|
|
|
command: string;
|
|
|
|
options: {};
|
|
|
|
global: {};
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:40:13 +00:00
|
|
|
export interface OptionDefinition {
|
2017-12-20 21:46:01 +00:00
|
|
|
signature: string;
|
|
|
|
description: string;
|
|
|
|
parameter?: string;
|
|
|
|
boolean?: boolean;
|
|
|
|
alias?: string | string[];
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:40:13 +00:00
|
|
|
export interface CommandDefinition<P = {}, O = {}> {
|
2017-12-20 21:46:01 +00:00
|
|
|
signature: string;
|
|
|
|
description: string;
|
|
|
|
help: string;
|
2018-01-04 14:07:55 +00:00
|
|
|
options?: OptionDefinition[];
|
|
|
|
permission?: 'user';
|
2017-12-20 21:46:01 +00:00
|
|
|
action(params: P, options: O, done: () => void): void;
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:40:13 +00:00
|
|
|
export interface Command {
|
|
|
|
signature: Signature;
|
|
|
|
options: Option[];
|
|
|
|
isWildcard(): boolean;
|
2017-12-20 21:46:01 +00:00
|
|
|
}
|
|
|
|
|
2017-12-21 17:40:13 +00:00
|
|
|
export interface Signature {
|
|
|
|
hasParameters(): boolean;
|
|
|
|
hasVariadicParameters(): boolean;
|
|
|
|
isWildcard(): boolean;
|
|
|
|
allowsStdin(): boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Option {
|
|
|
|
signature: Signature;
|
|
|
|
alias: string | string[];
|
|
|
|
boolean: boolean;
|
|
|
|
parameter: string;
|
|
|
|
required: boolean | string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function command(command: CommandDefinition): void;
|
2017-12-20 21:46:01 +00:00
|
|
|
|
|
|
|
export const state: {
|
2018-01-09 15:05:24 +00:00
|
|
|
getMatchCommand: (
|
|
|
|
signature: string,
|
|
|
|
callback: (e: Error, cmd: Command) => void,
|
|
|
|
) => void;
|
2017-12-20 21:46:01 +00:00
|
|
|
};
|
|
|
|
}
|