Skip to content
Myr

Switch from class to class-like to include all types in commander namespace

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by John Gee · parent 08a5f02 · Browse files · 1 file+11 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−34 removed

  • other:+11 added−34 removed

1 file+11 added−34 removed

modified:typings/index.d.ts+11 added-34 removed
3 unmodified lines
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped56///<reference types="node" />78declare namespace local {8declare namespace commander {910 class CommanderError extends Error {10 interface CommanderError extends Error {11 code: string;12 exitCode: number;13 message: string;14 nestedError?: string;1516 constructor(exitCode: number, code: string, message: string);15 }16 type CommanderErrorConstructor = { new (exitCode: number, code: string, message: string): CommanderError };1719 class Option {18 interface Option {19 flags: string;20 required: boolean; // A value must be supplied when the option is specified.21 optional: boolean; // A value is optional when the option is specified.22 mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.23 bool: boolean;24 short?: string;25 long: string;26 description: string;2829 /**30 * Initialize a new `Option` with the given `flags` and `description`.31 *32 * @param {string} flags33 * @param {string} [description]34 */35 constructor(flags: string, description?: string);27 }28 type OptionConstructor = { new (flags: string, description?: string): Option };2938 class Command extends NodeJS.EventEmitter {30 interface Command extends NodeJS.EventEmitter {31 [key: string]: any; // options as properties3233 args: string[];3435 /**44 * Initialize a new `Command`.45 *46 * @param {string} [name]47 */48 constructor(name?: string);4950 /**36 * Set the program version to `str`. 37 *38 * This method auto-registers the "-V, --version" flag39 * which will print the version number when passed.
22 unmodified lines
62 * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`63 * @param opts - configuration options64 * @returns new command65 */81 command(nameAndArgs: string, opts?: commander.CommandOptions): Command;66 command(nameAndArgs: string, opts?: CommandOptions): Command;67 /**68 * Define a command, implemented in a separate executable file.69 * 70 * @remarks
204 unmodified lines
275 * Output help information and exit.276 */277 help(cb?: (str: string) => string): never;278 }279 type CommandConstructor = { new (name?: string): Command };280295}281297declare namespace commander {298299 type Command = local.Command300301 type Option = local.Option302282 interface CommandOptions {283 noHelp?: boolean;284 isDefault?: boolean;285 executableFile?: string;
4 unmodified lines
290 unknown: string[];291 }292293 interface CommanderStatic extends Command {315 Command: typeof local.Command;316 Option: typeof local.Option;317 CommandOptions: CommandOptions;318 ParseOptionsResult: ParseOptionsResult;319 CommanderError : typeof local.CommanderError;294 Command: CommandConstructor;295 Option: OptionConstructor;296 CommanderError:CommanderErrorConstructor;297 }298299}300
2 unmodified lines