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