An example cli built with yargs.
pets
requires Node V5 or higher. To install, run:
npm install -g pets
or clone the package locally and npm link
it.
git clone git@github.com:eddywashere/pets.git
cd pets
npm install
npm link
pets <command> <subcommand> [--parameters]
Parameters can also be passed in via environment variables prefixed with PETS_CONFIG
.
Example:
PETS_CONFIG_NAMES="nymeria,tyrion" pets cats add
# equivalent to:
# pets cats add --names nymeria,tyrion
Commands are organized in subdirectories within the cmd
directory. Each subcommand is read from the subdirectories via .commandDir
. See yargs commandDir docs for more info.
In a real world example, the handler
for individual subcommands would contain real business logic to process the inputs.
Tests