Use standard import in examples (#2168)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by GitHub · parent dd2d8fb · Browse files · 39 files·+39 added−82 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
39 files+39 added−82 removed
- other:+39 added−82 removed
Provenance
- Commit
41b12cf- Tree
fd3c5f8- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
dd2d8fb
39 files changed+39 added−82 removed
modified:examples/action-this.js+1 added-2 removed
1234565678910 unmodified lines#!/usr/bin/env node
// This example is used as an example in the README for the action handler.
// const { Command } = require('commander'); // (normal include)const { Command } = require('../'); // include commander in git clone of commander repoconst { Command } = require('commander');const program = new Command();
program .command('serve')10 unmodified linesmodified:examples/alias.js+1 added-2 removed
1234565678927 unmodified lines#!/usr/bin/env node
// This example shows giving alternative names for a command.
// const { Command } = require('commander'); // (normal include)const { Command } = require('../'); // include commander in git clone of commander repoconst { Command } = require('commander');const program = new Command();
program .command('exec')27 unmodified linesmodified:examples/argument.js+1 added-2 removed
1234565678914 unmodified lines#!/usr/bin/env node
// This example shows specifying the command arguments using argument() function.
// const { Command } = require('commander'); // (normal include)const { Command } = require('../'); // include commander in git clone of commander repoconst { Command } = require('commander');const program = new Command();
program .name('connect')14 unmodified linesmodified:examples/arguments-custom-processing.js+1 added-2 removed
2 unmodified lines345678789101135 unmodified lines2 unmodified lines// This is used as an example in the README for:// Custom argument processing// You may specify a function to do custom processing of argument values.
// const commander = require('commander'); // (normal include)const commander = require('../'); // include commander in git clone of commander repoconst commander = require('commander');const program = new commander.Command();
function myParseInt(value, dummyPrevious) { // parseInt takes a string and a radix35 unmodified linesmodified:examples/arguments-extra.js+1 added-2 removed
1234565678913 unmodified lines#!/usr/bin/env node
// This is used as an example in the README for extra argument features.
// const commander = require('commander'); // (normal include)const commander = require('../'); // include commander in git clone of commander repoconst commander = require('commander');const program = new commander.Command();
program .addArgument(new commander.Argument('<drink-size>', 'drink cup size').choices(['small', 'medium', 'large']))13 unmodified linesmodified:examples/configure-help.js+1 added-3 removed
1231234519 unmodified lines// const commander = require('commander'); // (normal include)const commander = require('../'); // include commander in git clone of commander repo
const commander = require('commander');const program = new commander.Command();
// This example shows a simple use of configureHelp.// This is used as an example in the README.19 unmodified linesmodified:examples/configure-output.js+1 added-3 removed
1-// const commander = require('commander'); // (normal include)2-const commander = require('../'); // include commander in git clone of commander repo3-1+const commander = require('commander');2 const program = new commander.Command();3 4 function errorColor(str) {5 // Add ANSI escape codes to display text in red.24 unmodified linesmodified:examples/custom-command-class.js+1 added-3 removed
1 #!/usr/bin/env node2+const commander = require('commander');3 3-// const commander = require('commander'); // (normal include)4-const commander = require('../'); // include commander in git clone of commander repo5-4 // Use a class override to customise the command and its subcommands.5 6 class CommandWithTrace extends commander.Command {7 createCommand(name) {41 unmodified linesmodified:examples/custom-help+1 added-2 removed
1 unmodified line2 3 // This example shows a simple use of addHelpText.4 // This is used as an example in the README.5 6-// const { Command } = require('commander'); // (normal include)7-const { Command } = require('../'); // include commander in git clone of commander repo6+const { Command } = require('commander');7 const program = new Command();8 9 program10 .option('-f, --foo', 'enable some foo');10 unmodified linesmodified:examples/custom-help-description+1 added-2 removed
1 #!/usr/bin/env node2 3 // This example shows changing the flags and description for the help option.4 5-// const { Command } = require('commander'); // (normal include)6-const { Command } = require('../'); // include commander in git clone of commander repo5+const { Command } = require('commander');6 const program = new Command();7 8 program9 .helpOption('-c, --HELP', 'custom help message')15 unmodified linesmodified:examples/custom-help-text.js+1 added-2 removed
1 #!/usr/bin/env node2 3 // This example shows using addHelpText.4 5-// const { Command } = require('commander'); // (normal include)6-const { Command } = require('../'); // include commander in git clone of commander repo5+const { Command } = require('commander');6 const program = new Command();7 8 program.name('awesome');9 23 unmodified linesmodified:examples/custom-version+1 added-2 removed
1 #!/usr/bin/env node2 3 // This example shows changing the flags and description for the version option.4 5-// const { Command } = require('commander'); // (normal include)6-const { Command } = require('../'); // include commander in git clone of commander repo5+const { Command } = require('commander');6 const program = new Command();7 8 program9 .version('0.0.1', '-v, --VERSION', 'new version message')8 unmodified linesmodified:examples/defaultCommand.js+1 added-2 removed
1 #!/usr/bin/env node2 3-// const commander = require('commander'); // (normal include)4-const commander = require('../'); // include commander in git clone of commander repo3+const commander = require('commander');4 const program = new commander.Command();5 6 // Example program using the command configuration option isDefault to specify the default command.7 28 unmodified linesmodified:examples/deploy+1 added-2 removed
1 #!/usr/bin/env node2 3-// const { Command } = require('commander'); // (normal include)4-const { Command } = require('../'); // include commander in git clone of commander repo3+const { Command } = require('commander');4 const program = new Command();5 6 program7 .name('deploy')28 unmodified linesmodified:examples/description+1 added-2 removed
1 #!/usr/bin/env node2 3 // This example shows adding a description which is displayed in the help.4 5-// const { Command } = require('commander'); // (normal include)6-const { Command } = require('../'); // include commander in git clone of commander repo5+const { Command } = require('commander');6 const program = new Command();7 8 program9 .version('0.0.1')14 unmodified linesmodified:examples/global-options-added.js+1 added-2 removed
7 unmodified lines8 //9 // (A different pattern for a "global" option is to add it to the root command, rather10 // than to the subcommand. See global-options-nested.js.)11 12-// const { Command } = require('commander'); // (normal include)13-const { Command } = require('../'); // include commander in git clone of commander repo12+const { Command } = require('commander');13 14 // Common options can be added when subcommands are created by using a custom subclass.15 // If the options are unsorted in the help, these will appear first.16 class MyRootCommand extends Command {34 unmodified linesmodified:examples/global-options-nested.js+1 added-3 removed
4 unmodified lines5 //6 // (A different pattern for a "global" option is to add it to the subcommands, rather7 // than to the program. See global-options-added.js.)8 9-// const { Command } = require('commander'); // (normal include)10-const { Command } = require('../'); // include commander in git clone of commander repo11-9+const { Command } = require('commander');10 const program = new Command();11 12 program13 .configureHelp({ showGlobalOptions: true })17 unmodified linesmodified:examples/help-subcommands-usage.js+1 added-2 removed
1-// const commander = require('commander'); // (normal include)2-const commander = require('../'); // include commander in git clone of commander repo1+const commander = require('commander');2 3 // By default the subcommand list includes a fairly simple usage. If you have added a custom usage4 // to the subcommands you may wish to configure the help to show these instead.5 //23 unmodified linesmodified:examples/hook.js+1 added-2 removed
1 #!/usr/bin/env node2 3-// const commander = require('commander'); // (normal include)4-const { Command, Option } = require('../'); // include commander in git clone of commander repo3+const { Command, Option } = require('commander');4 const program = new Command();5 6 // This example shows using some hooks for life cycle events.7 57 unmodified linesmodified:examples/nestedCommands.js+1 added-2 removed
1 #!/usr/bin/env node2 3-// const commander = require('commander'); // (normal include)4-const commander = require('../'); // include commander in git clone of commander repo3+const commander = require('commander');4 const program = new commander.Command();5 6 // Commander supports nested subcommands.7 // .command() can add a subcommand with an action handler or an executable.38 unmodified linesmodified:examples/options-boolean-or-value.js+1 added-2 removed
2 unmodified lines3 // This is used as an example in the README for:4 // Other option types, flag|value5 // You can specify an option which functions as a flag but may also take a value (declared using square brackets).6 7-// const commander = require('commander'); // (normal include)8-const commander = require('../'); // include commander in git clone of commander repo7+const commander = require('commander');8 const program = new commander.Command();9 10 program11 .option('-c, --cheese [type]', 'Add cheese with optional type');12 unmodified linesmodified:examples/options-common.js+1 added-2 removed
1 unmodified line2 3 // This is used as an example in the README for:4 // Common option types, boolean and value5 6-// const commander = require('commander'); // (normal include)7-const commander = require('../'); // include commander in git clone of commander repo6+const commander = require('commander');7 const program = new commander.Command();8 9 program10 .option('-d, --debug', 'output extra debugging')15 unmodified linesmodified:examples/options-conflicts.js+1 added-2 removed
1 #!/usr/bin/env node2-// const { Command, Option } = require('commander'); // (normal include)3-const { Command, Option } = require('../'); // include commander in git clone of commander repo2+const { Command, Option } = require('commander');3 const program = new Command();4 5 // You can use .conflicts() with a single string, which is the camel-case name of the conflicting option.6 program64 unmodified linesmodified:examples/options-custom-processing.js+1 added-2 removed
2 unmodified lines3 // This is used as an example in the README for:4 // Custom option processing5 // You may specify a function to do custom processing of option values.6 7-// const commander = require('commander'); // (normal include)8-const commander = require('../'); // include commander in git clone of commander repo7+const commander = require('commander');8 const program = new commander.Command();9 10 function myParseInt(value, dummyPrevious) {11 // parseInt takes a string and a radix42 unmodified linesmodified:examples/options-defaults.js+1 added-2 removed
1 unmodified line2 3 // This is used as an example in the README for:4 // Default option value5 6-// const commander = require('commander'); // (normal include)7-const commander = require('../'); // include commander in git clone of commander repo6+const commander = require('commander');7 const program = new commander.Command();8 9 program10 .option('-c, --cheese <type>', 'Add the specified type of cheese', 'blue');8 unmodified linesmodified:examples/options-env.js+1 added-2 removed
1 #!/usr/bin/env node2-// const { Command, Option } = require('commander'); // (normal include)3-const { Command, Option } = require('../'); // include commander in git clone of commander repo2+const { Command, Option } = require('commander');3 const program = new Command();4 5 program.addOption(new Option('-p, --port <number>', 'specify port number')6 .default(80)31 unmodified linesmodified:examples/options-extra.js+1 added-2 removed
2 unmodified lines3 // This is used as an example in the README for extra option features.4 // See also options-env.js for more extensive env examples,5 // and options-conflicts.js for more details about .conflicts().6 7-// const { Command, Option } = require('commander'); // (normal include)8-const { Command, Option } = require('../'); // include commander in git clone of commander repo7+const { Command, Option } = require('commander');8 const program = new Command();9 10 program11 .addOption(new Option('-s, --secret').hideHelp())19 unmodified linesmodified:examples/options-implies.js+1 added-2 removed
1 #!/usr/bin/env node2-// const { Command, Option } = require('commander'); // (normal include)3-const { Command, Option } = require('../'); // include commander in git clone of commander repo2+const { Command, Option } = require('commander');3 const program = new Command();4 5 program6 .addOption(new Option('--quiet').implies({ logLevel: 'off' }))14 unmodified linesmodified:examples/options-negatable.js+1 added-2 removed
2 unmodified lines3 // This is used as an example in the README for:4 // Other option types, negatable boolean5 // You can specify a boolean option long name with a leading `no-` to make it true by default and able to be negated.6 7-// const commander = require('commander'); // (normal include)8-const commander = require('../'); // include commander in git clone of commander repo7+const commander = require('commander');8 const program = new commander.Command();9 10 program11 .option('--no-sauce', 'Remove sauce')15 unmodified linesmodified:examples/options-required.js+1 added-2 removed
3 unmodified lines4 // Required option5 // You may specify a required (mandatory) option using `.requiredOption`.6 // The option must be specified on the command line, or by having a default value.7 8-// const commander = require('commander'); // (normal include)9-const commander = require('../'); // include commander in git clone of commander repo8+const commander = require('commander');9 const program = new commander.Command();10 11 program12 .requiredOption('-c, --cheese <type>', 'pizza must have cheese');8 unmodified linesmodified:examples/options-variadic.js+1 added-2 removed
1 #!/usr/bin/env node2 3 // This is used as an example in the README for variadic options.4 5-// const commander = require('commander'); // (normal include)6-const commander = require('../'); // include commander in git clone of commander repo5+const commander = require('commander');6 const program = new commander.Command();7 8 program9 .option('-n, --number <value...>', 'specify numbers')11 unmodified linesmodified:examples/pass-through-options.js+1 added-2 removed
1 #!/usr/bin/env node2 3-// const { Command } = require('commander'); // (normal include)4-const { Command } = require('../'); // include commander in git clone of commander repo3+const { Command } = require('commander');4 const program = new Command();5 6 program7 .argument('<utility>')15 unmodified linesmodified:examples/pizza+1 added-2 removed
1 #!/usr/bin/env node2 3-// const { Command } = require('commander'); // (normal include)4-const { Command } = require('../'); // include commander in git clone of commander repo3+const { Command } = require('commander');4 const program = new Command();5 6 program7 .description('An application for pizza ordering')19 unmodified linesmodified:examples/pm+1 added-2 removed
1 #!/usr/bin/env node2 3-// const { Command } = require('commander'); // (normal include)4-const { Command } = require('../'); // include commander in git clone of commander repo3+const { Command } = require('commander');4 const program = new Command();5 6 // Example of subcommands which are implemented as stand-alone executable files.7 //25 unmodified linesmodified:examples/pm-install+1 added-2 removed
1 #!/usr/bin/env node2 3-// const { Command } = require('commander'); // (normal include)4-const { Command } = require('../'); // include commander in git clone of commander repo3+const { Command } = require('commander');4 const program = new Command();5 6 program7 .option('-f, --force', 'force installation');16 unmodified linesmodified:examples/positional-options.js+1 added-2 removed
1 #!/usr/bin/env node2 3-// const { Command } = require('commander'); // (normal include)4-const { Command } = require('../'); // include commander in git clone of commander repo3+const { Command } = require('commander');4 const program = new Command();5 6 program7 .enablePositionalOptions()18 unmodified linesmodified:examples/split.js+1 added-2 removed
1-// const { program } = require('commander'); // (normal include)2-const { program } = require('../'); // include commander in git clone of commander repo1+const { program } = require('commander');2 3 // This is used as an example in the README for the Quick Start.4 5 program13 unmodified linesmodified:examples/string-util.js+1 added-2 removed
1-// const { Command } = require('commander'); // (normal include)2-const { Command } = require('../'); // include commander in git clone of commander repo1+const { Command } = require('commander');2 const program = new Command();3 4 // This is used as an example in the README for the Quick Start.5 31 unmodified linesmodified:examples/thank.js+1 added-2 removed
1 #!/usr/bin/env node2 3 // This example is used as an example in the README for the action handler.4 5-// const { Command } = require('commander'); // (normal include)6-const { Command } = require('../'); // include commander in git clone of commander repo5+const { Command } = require('commander');6 const program = new Command();7 8 program9 .argument('<name>')16 unmodified lines