Skip to content
Myr

add info for git-style subcommand

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

authored by zhiyelee · committed by zhiyelee · parent af05389 · 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
70 unmodified lines
7172 An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed73 to your action as demonstrated above.7475## Git-style sub-commands7677```78// file: ./examples/pm79var program = require('..');8081program82 .version('0.0.1')83 .command('install [name]', 'install one or more packages')84 .command('search [query]', 'search with optional query')85 .command('list', 'list packages installed')86 .parse(process.argv);87```8889Here `.command()` is invoked with a description, and no `.action(callback)` calls to handle sub-commands. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.90The commander will try to find the executable script in __current directory__ with the name `scriptBasename-subcommand`, like `pm-install`, `pm-search`.9192## Automated --help9394 The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:95
160 unmodified lines