Skip to content
Myr

Merge pull request #295 from zhiyelee/git-style-readme

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

add info for git-style subcommand

authored by Zhiye Li · committed by Zhiye Li · parents 76754b8, ce5dd0d · Browse files · 1 file+17 added−0 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+17 added−0 removed

  • other:+17 added−0 removed

1 file+17 added−0 removed

modified:Readme.md+17 added
71 unmodified lines
7273 An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed74 to your action as demonstrated above.7576## Git-style sub-commands7778```js79// file: ./examples/pm80var program = require('..');8182program83 .version('0.0.1')84 .command('install [name]', 'install one or more packages')85 .command('search [query]', 'search with optional query')86 .command('list', 'list packages installed')87 .parse(process.argv);88```8990When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools. 91The commander will try to find the executable script in __current directory__ with the name `scriptBasename-subcommand`, like `pm-install`, `pm-search`.9293## Automated --help9495 The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:96
160 unmodified lines