2019-04-25 17:39:16 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2019 Balena Ltd.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
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;
|
2020-02-10 18:25:15 +00:00
|
|
|
required?: string;
|
2017-12-20 21:46:01 +00:00
|
|
|
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;
|
2019-05-28 16:31:18 +00:00
|
|
|
options?: Partial<OptionDefinition[]>;
|
2018-01-04 14:07:55 +00:00
|
|
|
permission?: 'user';
|
2018-05-22 15:12:51 +00:00
|
|
|
root?: boolean;
|
|
|
|
primary?: boolean;
|
2019-05-28 16:31:18 +00:00
|
|
|
action(params: P, options: Partial<O>, done: () => void): void;
|
2017-12-20 21:46:01 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|