Skip to content
Myr

Remove most uses of top-level, as less accurate now with command nesting. (#1230)

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

authored by John Gee · committed by GitHub · parent e960c90 · Browse files · 3 files+7 added−7 removed
This commit

State

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

Diff stats

3 files+7 added−7 removed

  • other:+7 added−7 removed

3 files+7 added−7 removed

modified:typings/index.d.ts+1 added-1 removed
101 unmodified lines
102 */103 addCommand(cmd: Command): this;104105 /**106 * Define argument syntax for the top-level command.106 * Define argument syntax for command.107 *108 * @returns Command for chaining109 */110 arguments(desc: string): this;
258 unmodified lines
modified:index.js+2 added-2 removed
151 unmodified lines
152 *153 * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`154 * @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)155 * @param {Object} [execOpts] - configuration options (for executable)156 * @return {Command} returns new command for action handler, or top-level command for executable command156 * @return {Command} returns new command for action handler, or `this` for executable command157 * @api public158 */159160 command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
79 unmodified lines
240 return this;241 };242243 /**244 * Define argument syntax for the top-level command.244 * Define argument syntax for the command.245 *246 * @api public247 */248
1464 unmodified lines
modified:Readme.md+4 added-4 removed
298 unmodified lines
299```300301## Commands302303You can specify (sub)commands for your top-level command using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).303You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).304305In the first parameter to `.command()` you specify the command name and any command arguments. The arguments may be `<required>` or `[optional]`, and the last argument may also be `variadic...`.306307You can use `.addCommand()` to add an already configured subcommand to the program.
10 unmodified lines
318 console.log('clone command called');319 });320321// Command implemented using stand-alone executable file (description is second parameter to `.command`)322// Returns top-level command for adding more commands.322// Returns `this` for adding more commands.323program324 .command('start <service>', 'start named service')325 .command('stop [service]', 'stop named service, or all if no name supplied');326327// Command prepared separately.328// Returns top-level command for adding more commands.328// Returns `this` for adding more commands.329program330 .addCommand(build.makeBuildCommand());331```332333Configuration options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the command from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified ([example](./examples/defaultCommand.js)).334335### Specify the argument syntax336337You use `.arguments` to specify the arguments for the top-level command, and for subcommands they are included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required input. Square brackets (e.g. `[optional]`) indicate optional input.337You use `.arguments` to specify the arguments for the top-level command, and for subcommands they are usually included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required input. Square brackets (e.g. `[optional]`) indicate optional input.338339```js340const { program } = require('commander');341
396 unmodified lines