Skip to content
Myr

Fix #376: add documentation for arguments() method

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

authored by Reuben Thomas · committed by Reuben Thomas · parent dae7802 · Browse files · 3 files+47 added−2 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+47 added−2 removed

  • tests:+2 added−2 removed
  • other:+45 added−0 removed

3 files+47 added−2 removed

added:examples/env+20 added
1#!/usr/bin/env node23var program = require('../');45program6 .version('0.0.1')7 .arguments('<cmd> [env]')8 .action(function (cmd, env) {9 cmdValue = cmd;10 envValue = env;11 });1213program.parse(process.argv);1415if (typeof cmdValue === 'undefined') {16 console.error('no command given!');17 process.exit(1);18}19console.log('command:', cmdValue);20console.log('environment:', envValue || "no environment given");
modified:test/test.arguments.js+2 added-2 removed
modified:Readme.md+25 added
130 unmodified lines
131132 An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed133 to your action as demonstrated above.134135## Specify the argument syntax136137```js138#!/usr/bin/env node139140var program = require('../');141142program143 .version('0.0.1')144 .arguments('<cmd> [env]')145 .action(function (cmd, env) {146 cmdValue = cmd;147 envValue = env;148 });149150program.parse(process.argv);151152if (typeof cmdValue === 'undefined') {153 console.error('no command given!');154 process.exit(1);155}156console.log('command:', cmdValue);157console.log('environment:', envValue || "no environment given");158```159160## Git-style sub-commands161162```js163// file: ./examples/pm
174 unmodified lines