How to use the args function from commander

Find comprehensive JavaScript commander.args code examples handpicked from public code repositorys.

26
27
28
29
30
31
32
33
34
35
    console.log('  juji faq -b mybrandid -e engagementorder -o my_faq.csv');
});

program.parse(process.argv);

var args = program.args;

if (!args.length) {
    console.error('Input file is required');
    console.log('');
fork icon0
star icon6
watch icon0

+ 3 other calls in file

19
20
21
22
23
24
25
26
27
28
}

// --segment <segment> 是可选项,当后面带的不合法的 segment 时,当作文本处理。
const validSegmentList = ["nodejieba", "@node-rs/jieba", "segmentit", true, false, undefined];
if (!validSegmentList.includes(commander.segment)) {
  commander.args.splice(0, 0, commander.segment);
  commander.segment = true;
}
// output help and exit if no args found
if (commander.args.length === 0) {
fork icon832
star icon0
watch icon144

+ 41 other calls in file

30
31
32
33
34
35
36
37
38
39
  .option('--eval <functionBody>', 'Uses a function to scrape, providing only it\'s body.')
  .option('-s, --static', 'Uses the static scraper. Used by default.', true)
  .option('-d, --dynamic', 'Uses the dynamic scraper.', false)
  .parse(process.argv);

var urls = program.args;
var ScraperType = (program.dynamic ? 'Dynamic' : 'Static' ) + 'Scraper';
var fn, args;

if(program.selector && (program.text || program.html || program.attr)) {
fork icon201
star icon0
watch icon94

+ 13 other calls in file

77
78
79
80
81
82
83
84
85
86
qrcode.generate(cerURL);
console.log('Install CA certification on iOS 11 ' + cerURL);
console.log('\n');
qrcode.generate(downloadURL);
console.log('Open download page ' + downloadURL);
var destinationPath = program.args.shift() || '.';
var ipasDir = destinationPath;

var key;
var cert;
fork icon188
star icon759
watch icon40

+ 11 other calls in file

77
78
79
80
81
82
83
84
85
86

if (program.absolute) format = format.toUpperCase()

var options = !named ? {} : {
  cwd: program.args[program.args.length - 1],
  packages: program.args.slice(0, program.args.length - 1),
  recursive: recursive
}

if (named) {
fork icon19
star icon352
watch icon9

+ 38 other calls in file

71
72
73
74
75
76
77
78
79
80
if (!program.args.length) {
  console.error('No icons specified!'); // eslint-disable-line
  process.exit(1);
}

const files = program.args.flatMap((file) => glob.sync(file));
const options = program.opts();

new SVGIconsDirStream(files, {
  startUnicode: options.startunicode,
fork icon73
star icon316
watch icon10

+ 14 other calls in file

233
234
235
236
237
238
239
        consoleLogger);
    });

// error on unknown commands
cmd.on('command:*', function () {
    console.error('Invalid command: %s\nSee --help for a list of available commands.', cmd.args.join(' '));
    process.exit(1);
fork icon18
star icon64
watch icon12

+ 7 other calls in file

23
24
25
26
27
28
29
30
31
32
  .usage('<option> [query string]')
  // .option('-l, --list [format]', 'Print with format [%s]')
  .on('--help', print_help)
  .parse(process.argv);

let query = program.args.join('+');

if (!query) return print_help();

netid
fork icon1
star icon36
watch icon4

67
68
69
70
71
72
73
74

function loadRecipients(cb) {
  if (program.recipients) {
    recipients.jsonLines(program.recipients, cb);
  } else {
    cb(null, program.args.slice(1).map((r) => ({to: r})));
  }
}
fork icon0
star icon1
watch icon2

+ 9 other calls in file

171
172
173
174
175
176
177
178
179
180
});

//
// Metrics collection.
//
var metrics = new Metrics(cli.amount * cli.args.length);

// Iterate over all the urls so we can target multiple locations at once, which
// is helpfull if you are testing multiple loadbalancer endpoints for example.
async.forEach(cli.args, function forEach(url, done) {
fork icon165
star icon0
watch icon35

+ 5 other calls in file

72
73
74
75
76
77
78
79
80
program.on('command:*', () => {
  logger.error(
    chalk.red(
      'Invalid command: %s\nSee --help for a list of available commands.'
    ),
    program.args.join(' ')
  )
  process.exit(1)
})
fork icon0
star icon5
watch icon0

+ 3 other calls in file

16
17
18
19
20
21
22
23
24
25
  ].join('\n\n'));
});
program.parse(process.argv);
const action = program.args[0];
const verbose = program.verbose;
const args = program.args;

if (!action) {
  git.print();
} else {
fork icon1
star icon1
watch icon11

194
195
196
197
198
199
200
201
202
203
    }
}

program.parse(process.argv);

const args = program.args

if (args.length === 1) {
    switch (args[0]) {
        case 'self': {
fork icon64
star icon412
watch icon39

26
27
28
29
30
31
32
33
34
35
program
        .option('-$, --usd [amount]', 'Amount of US Dollars to spend.')
        .option('-e, --exchange [name]', 'A specific exchange to buy from.')
        .parse(process.argv);

let symbol = program.args;

if (!symbol.length) {
        console.error(chalk.red('No coin symbol provided.'));
        process.exit(1);
fork icon37
star icon2
watch icon2

46
47
48
49
50
51
52
53
54
55
} else {
  fn = huxley.defaultWorkflow;
}

// globs, browserName, serverUrl, callback
// every unamed param is treated as a path to search in app.args
var opts = {
  globs: app.args,
  browserName: app.browser,
  serverUrl: app.server,
fork icon31
star icon365
watch icon17

50
51
52
53
54
55
56
57
58
  .option('-q, --quota <n>', 'Quota for the conference', parseInt, 10)
  .option('-f, --fee <n>', 'Fee to attend the conference', parseInt, 1000)
  .description('Deploy contract')
  .parse(process.argv)

const organizer = program.args.pop()
if (!organizer) {
  lib.handleError('Please specify the organizer\'s account')
}
fork icon7
star icon16
watch icon5

60
61
62
63
64
65
66
67
68
69
}



//daemonize?
if(program.daemonize && program.args.indexOf('is-daemon') === -1) {
  var path = program.daemonize;
  var spawn = require('child_process').spawn;
  
  var prog = process.argv[1];
fork icon3
star icon7
watch icon5

15
16
17
18
19
20
21
22
23
24
  .option('-v, --verbose', '(optional) Enable STDOUT logger in your Dragonchain SDK')
  .option('-i, --dragonchainId [dragonchainID]', '(optional) Override the default dragonchain ID for this command')
  .parse(process.argv);

util.wrapper(program, async client => {
  const [name] = program.args;
  const { satoshisPerByte, data, change, outputs } = program;
  if (!name) throw new Error("Parameter 'name' must be provided");
  const response = await client.signBitcoinTransaction(
    util.removeUndefined({
fork icon3
star icon6
watch icon10

20
21
22
23
24
25
26
27
28
29

if (program.args.length < 1) {
  throw 'not enough arguments, expected <version>';
}

const [tag] = program.args;
const version = tag.replace(/^v/, '');

const cdnUrl = `https://cdn-origin.vaadin.com/${elementName}/${version}/`;
const cdnApi = createAPI({baseURL: cdnUrl});
fork icon3
star icon4
watch icon13

94
95
96
97
98
99
100
101
102
103
if (app.starred) {
  starred = true
}

if (typeof app.stdin === 'undefined') {
  var title = app.args.join(' ')

  if (!title) {
    process.exit(1)
  }
fork icon31
star icon0
watch icon2

Other functions in commander

Sorted by popularity

function icon

commander.Option is the most popular function in commander (1786 examples)