-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into release/9.x
- Loading branch information
Showing
14 changed files
with
484 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
// const { Command, Option } = require('commander'); // (normal include) | ||
const { Command, Option } = require('../'); // include commander in git clone of commander repo | ||
const program = new Command(); | ||
|
||
program.addOption(new Option('-p, --port <number>', 'specify port number') | ||
.default(80) | ||
.env('PORT') | ||
); | ||
program.addOption(new Option('-c, --colour', 'turn on colour output') | ||
.env('COLOUR') | ||
); | ||
program.addOption(new Option('-C, --no-colour', 'turn off colour output') | ||
.env('NO_COLOUR') | ||
); | ||
program.addOption(new Option('-s, --size <type>', 'specify size of drink') | ||
.choices(['small', 'medium', 'large']) | ||
.env('SIZE') | ||
); | ||
|
||
program.parse(); | ||
console.log(program.opts()); | ||
|
||
// Try the following: | ||
// node options-env.js --help | ||
// | ||
// node options-env.js | ||
// PORT=9001 node options-env.js | ||
// PORT=9001 node options-env.js --port 123 | ||
// | ||
// COLOUR= node options-env.js | ||
// COLOUR= node options-env.js --no-colour | ||
// NO_COLOUR= node options-env.js | ||
// NO_COLOUR= node options-env.js --colour | ||
// | ||
// SIZE=small node options-env.js | ||
// SIZE=enormous node options-env.js | ||
// SIZE=enormous node options-env.js --size=large |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
#!/usr/bin/env node | ||
|
||
// This is used as an example in the README for extra option features. | ||
// See also options-env.js for more extensive env examples. | ||
|
||
// const commander = require('commander'); // (normal include) | ||
const commander = require('../'); // include commander in git clone of commander repo | ||
const program = new commander.Command(); | ||
// const { Command, Option } = require('commander'); // (normal include) | ||
const { Command, Option } = require('../'); // include commander in git clone of commander repo | ||
const program = new Command(); | ||
|
||
program | ||
.addOption(new commander.Option('-s, --secret').hideHelp()) | ||
.addOption(new commander.Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute')) | ||
.addOption(new commander.Option('-d, --drink <size>', 'drink cup size').choices(['small', 'medium', 'large'])); | ||
.addOption(new Option('-s, --secret').hideHelp()) | ||
.addOption(new Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute')) | ||
.addOption(new Option('-d, --drink <size>', 'drink cup size').choices(['small', 'medium', 'large'])) | ||
.addOption(new Option('-p, --port <number>', 'port number').env('PORT')); | ||
|
||
program.parse(); | ||
|
||
console.log('Options: ', program.opts()); | ||
|
||
// Try the following: | ||
// node options-extra.js --help | ||
// node options-extra.js --drink huge | ||
// node options-extra.js --help | ||
// node options-extra.js --drink huge | ||
// PORT=80 node options-extra.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.