Skip to content
Myr

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

39 files+39 added−82 removed

modified:examples/action-this.js+1 added-2 removed
modified:examples/alias.js+1 added-2 removed
modified:examples/argument.js+1 added-2 removed
modified:examples/arguments-custom-processing.js+1 added-2 removed
modified:examples/arguments-extra.js+1 added-2 removed
modified:examples/configure-help.js+1 added-3 removed
modified:examples/configure-output.js+1 added-3 removed
1// const commander = require('commander'); // (normal include)2const commander = require('../'); // include commander in git clone of commander repo31const commander = require('commander');2const program = new commander.Command();34function errorColor(str) {5 // Add ANSI escape codes to display text in red.
24 unmodified lines
modified:examples/custom-command-class.js+1 added-3 removed
1#!/usr/bin/env node2const commander = require('commander');33// const commander = require('commander'); // (normal include)4const commander = require('../'); // include commander in git clone of commander repo54// Use a class override to customise the command and its subcommands.56class CommandWithTrace extends commander.Command {7 createCommand(name) {
41 unmodified lines
modified:examples/custom-help+1 added-2 removed
1 unmodified line
23// This example shows a simple use of addHelpText.4// This is used as an example in the README.56// const { Command } = require('commander'); // (normal include)7const { Command } = require('../'); // include commander in git clone of commander repo6const { Command } = require('commander');7const program = new Command();89program10 .option('-f, --foo', 'enable some foo');
10 unmodified lines
modified:examples/custom-help-description+1 added-2 removed
1#!/usr/bin/env node23// This example shows changing the flags and description for the help option.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo5const { Command } = require('commander');6const program = new Command();78program9 .helpOption('-c, --HELP', 'custom help message')
15 unmodified lines
modified:examples/custom-help-text.js+1 added-2 removed
1#!/usr/bin/env node23// This example shows using addHelpText.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo5const { Command } = require('commander');6const program = new Command();78program.name('awesome');9
23 unmodified lines
modified:examples/custom-version+1 added-2 removed
1#!/usr/bin/env node23// This example shows changing the flags and description for the version option.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo5const { Command } = require('commander');6const program = new Command();78program9 .version('0.0.1', '-v, --VERSION', 'new version message')
8 unmodified lines
modified:examples/defaultCommand.js+1 added-2 removed
1#!/usr/bin/env node23// const commander = require('commander'); // (normal include)4const commander = require('../'); // include commander in git clone of commander repo3const commander = require('commander');4const program = new commander.Command();56// Example program using the command configuration option isDefault to specify the default command.7
28 unmodified lines
modified:examples/deploy+1 added-2 removed
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo3const { Command } = require('commander');4const program = new Command();56program7 .name('deploy')
28 unmodified lines
modified:examples/description+1 added-2 removed
1#!/usr/bin/env node23// This example shows adding a description which is displayed in the help.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo5const { Command } = require('commander');6const program = new Command();78program9 .version('0.0.1')
14 unmodified lines
modified:examples/global-options-added.js+1 added-2 removed
7 unmodified lines
8//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.)1112// const { Command } = require('commander'); // (normal include)13const { Command } = require('../'); // include commander in git clone of commander repo12const { Command } = require('commander');1314// 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.16class MyRootCommand extends Command {
34 unmodified lines
modified:examples/global-options-nested.js+1 added-3 removed
4 unmodified lines
5//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.)89// const { Command } = require('commander'); // (normal include)10const { Command } = require('../'); // include commander in git clone of commander repo119const { Command } = require('commander');10const program = new Command();1112program13 .configureHelp({ showGlobalOptions: true })
17 unmodified lines
modified:examples/help-subcommands-usage.js+1 added-2 removed
1// const commander = require('commander'); // (normal include)2const commander = require('../'); // include commander in git clone of commander repo1const commander = require('commander');23// 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 lines
modified:examples/hook.js+1 added-2 removed
1#!/usr/bin/env node23// const commander = require('commander'); // (normal include)4const { Command, Option } = require('../'); // include commander in git clone of commander repo3const { Command, Option } = require('commander');4const program = new Command();56// This example shows using some hooks for life cycle events.7
57 unmodified lines
modified:examples/nestedCommands.js+1 added-2 removed
1#!/usr/bin/env node23// const commander = require('commander'); // (normal include)4const commander = require('../'); // include commander in git clone of commander repo3const commander = require('commander');4const program = new commander.Command();56// Commander supports nested subcommands.7// .command() can add a subcommand with an action handler or an executable.
38 unmodified lines
modified:examples/options-boolean-or-value.js+1 added-2 removed
2 unmodified lines
3// 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).67// const commander = require('commander'); // (normal include)8const commander = require('../'); // include commander in git clone of commander repo7const commander = require('commander');8const program = new commander.Command();910program11 .option('-c, --cheese [type]', 'Add cheese with optional type');
12 unmodified lines
modified:examples/options-common.js+1 added-2 removed
1 unmodified line
23// This is used as an example in the README for:4// Common option types, boolean and value56// const commander = require('commander'); // (normal include)7const commander = require('../'); // include commander in git clone of commander repo6const commander = require('commander');7const program = new commander.Command();89program10 .option('-d, --debug', 'output extra debugging')
15 unmodified lines
modified:examples/options-conflicts.js+1 added-2 removed
1#!/usr/bin/env node2// const { Command, Option } = require('commander'); // (normal include)3const { Command, Option } = require('../'); // include commander in git clone of commander repo2const { Command, Option } = require('commander');3const program = new Command();45// You can use .conflicts() with a single string, which is the camel-case name of the conflicting option.6program
64 unmodified lines
modified:examples/options-custom-processing.js+1 added-2 removed
2 unmodified lines
3// 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.67// const commander = require('commander'); // (normal include)8const commander = require('../'); // include commander in git clone of commander repo7const commander = require('commander');8const program = new commander.Command();910function myParseInt(value, dummyPrevious) {11 // parseInt takes a string and a radix
42 unmodified lines
modified:examples/options-defaults.js+1 added-2 removed
1 unmodified line
23// This is used as an example in the README for:4// Default option value56// const commander = require('commander'); // (normal include)7const commander = require('../'); // include commander in git clone of commander repo6const commander = require('commander');7const program = new commander.Command();89program10 .option('-c, --cheese <type>', 'Add the specified type of cheese', 'blue');
8 unmodified lines
modified:examples/options-env.js+1 added-2 removed
1#!/usr/bin/env node2// const { Command, Option } = require('commander'); // (normal include)3const { Command, Option } = require('../'); // include commander in git clone of commander repo2const { Command, Option } = require('commander');3const program = new Command();45program.addOption(new Option('-p, --port <number>', 'specify port number')6 .default(80)
31 unmodified lines
modified:examples/options-extra.js+1 added-2 removed
2 unmodified lines
3// 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().67// const { Command, Option } = require('commander'); // (normal include)8const { Command, Option } = require('../'); // include commander in git clone of commander repo7const { Command, Option } = require('commander');8const program = new Command();910program11 .addOption(new Option('-s, --secret').hideHelp())
19 unmodified lines
modified:examples/options-implies.js+1 added-2 removed
1#!/usr/bin/env node2// const { Command, Option } = require('commander'); // (normal include)3const { Command, Option } = require('../'); // include commander in git clone of commander repo2const { Command, Option } = require('commander');3const program = new Command();45program6 .addOption(new Option('--quiet').implies({ logLevel: 'off' }))
14 unmodified lines
modified:examples/options-negatable.js+1 added-2 removed
2 unmodified lines
3// 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.67// const commander = require('commander'); // (normal include)8const commander = require('../'); // include commander in git clone of commander repo7const commander = require('commander');8const program = new commander.Command();910program11 .option('--no-sauce', 'Remove sauce')
15 unmodified lines
modified:examples/options-required.js+1 added-2 removed
3 unmodified lines
4// 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.78// const commander = require('commander'); // (normal include)9const commander = require('../'); // include commander in git clone of commander repo8const commander = require('commander');9const program = new commander.Command();1011program12 .requiredOption('-c, --cheese <type>', 'pizza must have cheese');
8 unmodified lines
modified:examples/options-variadic.js+1 added-2 removed
1#!/usr/bin/env node23// This is used as an example in the README for variadic options.45// const commander = require('commander'); // (normal include)6const commander = require('../'); // include commander in git clone of commander repo5const commander = require('commander');6const program = new commander.Command();78program9 .option('-n, --number <value...>', 'specify numbers')
11 unmodified lines
modified:examples/pass-through-options.js+1 added-2 removed
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo3const { Command } = require('commander');4const program = new Command();56program7 .argument('<utility>')
15 unmodified lines
modified:examples/pizza+1 added-2 removed
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo3const { Command } = require('commander');4const program = new Command();56program7 .description('An application for pizza ordering')
19 unmodified lines
modified:examples/pm+1 added-2 removed
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo3const { Command } = require('commander');4const program = new Command();56// Example of subcommands which are implemented as stand-alone executable files.7//
25 unmodified lines
modified:examples/pm-install+1 added-2 removed
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo3const { Command } = require('commander');4const program = new Command();56program7 .option('-f, --force', 'force installation');
16 unmodified lines
modified:examples/positional-options.js+1 added-2 removed
1#!/usr/bin/env node23// const { Command } = require('commander'); // (normal include)4const { Command } = require('../'); // include commander in git clone of commander repo3const { Command } = require('commander');4const program = new Command();56program7 .enablePositionalOptions()
18 unmodified lines
modified:examples/split.js+1 added-2 removed
1// const { program } = require('commander'); // (normal include)2const { program } = require('../'); // include commander in git clone of commander repo1const { program } = require('commander');23// This is used as an example in the README for the Quick Start.45program
13 unmodified lines
modified:examples/string-util.js+1 added-2 removed
1// const { Command } = require('commander'); // (normal include)2const { Command } = require('../'); // include commander in git clone of commander repo1const { Command } = require('commander');2const program = new Command();34// This is used as an example in the README for the Quick Start.5
31 unmodified lines
modified:examples/thank.js+1 added-2 removed
1#!/usr/bin/env node23// This example is used as an example in the README for the action handler.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo5const { Command } = require('commander');6const program = new Command();78program9 .argument('<name>')
16 unmodified lines