Skip to content
Myr

Replace git-style wording from README (#1171)

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

* Remove git-style from docs * Remove stale comment

authored by John Gee · committed by GitHub · parent a094ef2 · Browse files · 2 files+9 added−9 removed
This commit

State

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

Diff stats

2 files+9 added−9 removed

  • tests:+1 added−1 removed
  • other:+8 added−8 removed

2 files+9 added−9 removed

modified:tests/command.asterisk.test.js+1 added-1 removed
modified:Readme.md+8 added-8 removed
20 unmodified lines
21 - [Version option](#version-option)22 - [Commands](#commands)23 - [Specify the argument syntax](#specify-the-argument-syntax)24 - [Action handler (sub)commands](#action-handler-subcommands)25 - [Git-style executable (sub)commands](#git-style-executable-subcommands)25 - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)26 - [Automated help](#automated-help)27 - [Custom help](#custom-help)28 - [.usage and .name](#usage-and-name)29 - [.help(cb)](#helpcb)
5 unmodified lines
35 - [Bits and pieces](#bits-and-pieces)36 - [Avoiding option name clashes](#avoiding-option-name-clashes)37 - [TypeScript](#typescript)38 - [Node options such as `--harmony`](#node-options-such-as---harmony)39 - [Debugging executable subcommands](#debugging-executable-subcommands)39 - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)40 - [Override exit handling](#override-exit-handling)41 - [Examples](#examples)42 - [License](#license)43 - [Support](#support)
253 unmodified lines
297```298299## Commands300301You 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 separate executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).301You 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)).302303In 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...`.304305You can use `.addCommand()` to add an already configured subcommand to the program.
9 unmodified lines
315 .action((source, destination) => {316 console.log('clone command called');317 });318319// Command implemented using separate executable file (description is second parameter to `.command`)319// Command implemented using stand-alone executable file (description is second parameter to `.command`)320// Returns top-level command for adding more commands.321program322 .command('start <service>', 'start named service')323 .command('stop [service]', 'stop named service, or all if no name supplied');
87 unmodified lines
411```412413A command's options on the command line are validated when the command is used. Any unknown options will be reported as an error.414415### Git-style executable (sub)commands415### Stand-alone executable (sub)commands416417When `.command()` is invoked with a description argument, this tells commander that you're going to use separate executables for sub-commands, much like `git` and other popular tools.417When `.command()` is invoked with a description argument, this tells Commander that you're going to use stand-alone executables for sub-commands.418Commander will search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-subcommand`, like `pm-install`, `pm-search`.419You can specify a custom name with the `executableFile` configuration option.420421You handle the options for an executable (sub)command in the executable, and don't declare them at the top-level.
182 unmodified lines
604### TypeScript605606The Commander package includes its TypeScript Definition file.607608If you use `ts-node` and git-style sub-commands written as `.ts` files, you need to call your program through node to get the sub-commands called correctly. e.g.608If you use `ts-node` and stand-alone executable sub-commands written as `.ts` files, you need to call your program through node to get the sub-commands called correctly. e.g.609610```bash611node -r ts-node/register pm.ts612```
4 unmodified lines
617618- Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. (Note Windows does not support this pattern.)619- Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.620621### Debugging executable subcommands621### Debugging stand-alone executable subcommands622623An executable subcommand is launched as a separate child process.624625If you are using the node inspector for [debugging](https://nodejs.org/en/docs/guides/debugging-getting-started/) executable subcommands using `node --inspect` et al,
79 unmodified lines