How to use commander

Comprehensive commander code examples:

How to use commander.release:

36
37
38
39
40
41
42
43
44
45
46
   program.release = release;
 }


 pkginfo.version = version;
 pkginfo.release = release;
 release = program.release;


var date = new Date().toUTCString().replace(/ [^ ]+$/, ' +0000');
var changelog = `${pkginfo.name} (${version}-${release}) unstable; urgency=low

How to use commander.usageMinusWildcard:

247
248
249
250
251
252
253
254
 */


program.parse(process.argv);
const NO_COMMAND_SPECIFIED = program.args.length === 0;
if (NO_COMMAND_SPECIFIED) {
  program.usageMinusWildcard();
}

How to use commander.global:

28
29
30
31
32
33
34
35
36
37
38
39
}


var render = dot.process({
		path: program.source,
		destination: program.dest,
		global: program.global
	});


if (program.package) {
	console.log("Packaging all files into " + program.package);

How to use commander.recipients:

56
57
58
59
60
61
62
63
64
65
66
67
) {
  program.help();
}


if (program.recipients) {
  recipients = program.recipients.split(',').join(', ');
}


transporter = nodemailer.createTransport(
  'smtps://' + program.user + ':' + program.password + '@' + program.smtp

How to use commander.browser:

544
545
546
547
548
549
550
551
552
553

console.error("FAIL! " + key);
listOfFailed.push(key);
exitStatus = 3;
if (opts.diff || opts.new) {
    const filenamePrefix = key + "-" + opts.browser;
    const outputDir = opts.new ? newDir : diffDir;
    const baseFile = path.join(dstDir, filenamePrefix + ".png");
    const diffFile = path.join(diffDir, filenamePrefix + "-diff.png");
    const bufFile = path.join(outputDir, filenamePrefix + ".png");

How to use commander.package:

12
13
14
15
16
17
18
19
20
21
22
23
	.option('-p, --package [value]', 'if specified, package all templates from destination folder into specified file')
	.parse(process.argv);


if (program.dest) mkdirordie(program.dest);
if (program.package) {
	var li = program.package.lastIndexOf('/');
	if (li>0) mkdirordie(program.package.substring(0, li));
}


function mkdirordie(path) {

How to use commander.katexUrl:

89
90
91
92
93
94
95
96
97
98
99
100
}


let seleniumURL = opts.seleniumUrl;
let seleniumIP = opts.seleniumIp;
let seleniumPort = opts.seleniumPort;
let katexURL = opts.katexUrl;
let katexIP = opts.katexIp;
let katexPort = opts.katexPort;


let bsLocal;

How to use commander.katexPort:

91
92
93
94
95
96
97
98
99
100
101
let seleniumURL = opts.seleniumUrl;
let seleniumIP = opts.seleniumIp;
let seleniumPort = opts.seleniumPort;
let katexURL = opts.katexUrl;
let katexIP = opts.katexIp;
let katexPort = opts.katexPort;


let bsLocal;
if (opts.browserstack) {
    // https://www.browserstack.com/automate/node

How to use commander.katexIp:

90
91
92
93
94
95
96
97
98
99
100
101


let seleniumURL = opts.seleniumUrl;
let seleniumIP = opts.seleniumIp;
let seleniumPort = opts.seleniumPort;
let katexURL = opts.katexUrl;
let katexIP = opts.katexIp;
let katexPort = opts.katexPort;


let bsLocal;
if (opts.browserstack) {

How to use commander.seleniumUrl:

86
87
88
89
90
91
92
93
94
95
96
    listOfCases = listOfCases.filter(function(key) {
        return exclude.indexOf(key) === -1;
    });
}


let seleniumURL = opts.seleniumUrl;
let seleniumIP = opts.seleniumIp;
let seleniumPort = opts.seleniumPort;
let katexURL = opts.katexUrl;
let katexIP = opts.katexIp;

How to use commander.seleniumIp:

87
88
89
90
91
92
93
94
95
96
97
        return exclude.indexOf(key) === -1;
    });
}


let seleniumURL = opts.seleniumUrl;
let seleniumIP = opts.seleniumIp;
let seleniumPort = opts.seleniumPort;
let katexURL = opts.katexUrl;
let katexIP = opts.katexIp;
let katexPort = opts.katexPort;

How to use commander.seleniumPort:

88
89
90
91
92
93
94
95
96
97
98
    });
}


let seleniumURL = opts.seleniumUrl;
let seleniumIP = opts.seleniumIp;
let seleniumPort = opts.seleniumPort;
let katexURL = opts.katexUrl;
let katexIP = opts.katexIp;
let katexPort = opts.katexPort;

How to use commander.registry:

20
21
22
23
24
25
26
27
28
29
//   debug: `service:*,${debug}`,
//   contractProvider: PlasmaCore.providers.ContractProviders.ContractProvider,
//   walletProvider: wallets[program.wallet],
//   operatorProvider: PlasmaCore.providers.OperatorProviders.HttpOperatorProvider,
//   plasmaChainName: program.chain,
//   registryAddress: program.registry
// }

const options = {
  address: program.address,

How to use commander.info:

91
92
93
94
95
96
97
98
99
100
tranJson(source, target, {
    transfer: program.translation,
    from: env.getTargetTo(baseLanguage),
    to: env.getTargetTo(lan),
    debug: program.debug,
    arrayResult: program.info
}).then(data => {
    if (program.info) {
        let content = JSON.stringify(util.ExpandJson({...data[1], ...data[2]}), null, "\t");
        util.writeFileRecursive(targetFilePath, content);

How to use commander.message:

94
95
96
97
98
99
100
101
102
103

// Now that we have our data, determine what we need
(async () => {

    // Get our data
    let message = program.message;
    let files = [];

    // Get our files if we are reading them
    if (program.dir || program.file) {

How to use commander.quiet:

21
22
23
24
25
26
27
28

if (program.poll) {
  opts.chokidar = { usePolling: true }
}

opts.quiet = program.quiet

chokidarEvEmitter(opts)

How to use commander.memory:

67
68
69
70
71
72
73
74
75
76
program.deps = program.deps || [];

var config = {};

if(program.functionName) config.name = program.functionName;
if(program.memory) config.memory = program.memory;
if(program.timeout) config.timeout = program.timeout;
if(program.functionDescription) config.description = program.functionDescription;

lambdaws.create(program.module, program.function, program.deps, config);

How to use commander.height:

35
36
37
38
39
40
41
42
43
44
    console.log(chalk.green.bold('no height'));;
} else if (program.height === true) {
    console.log(chalk.green.bold('add height'));;
} else {
    console.log(chalk.green.bold(`add height type ${chalk.blue.bold(program.height)}`));
    height = program.height;
}
if (program.inputImage === undefined) {
    console.log(chalk.green.bold('no inputImage'));;
} else if (program.inputImage === true) {

How to use commander.headers:

63
64
65
66
67
68
69
70
71
72
   program.outputHelp();
   process.exit(1);
}

if (typeof program.headers !== 'undefined') {
    allowedHeaders = program.headers;
}

if (typeof program.source === 'undefined') {
   console.error('No source map provided.');

How to use commander.due:

82
83
84
85
86
87
88
89
90
91
  dueDate = moment().add(1, 'day').format('YYYY-MM-DD')
}

if (app.due) {
  if (/\d{4}\-\d{2}\-\d{2}/.test(app.due)) {
    dueDate = app.due
  } else {
    console.error('Invalid due date!')
    process.exit(1)
  }

How to use commander._displayError:

115
116
117
118
119
120
121
122
123
124
//
// Function definitions
//

function invalidateAndExit (errorType, message) {
  program._displayError(1, errorType, message)
  process.exit(1)
}

async function deploy () {

How to use commander.cf:

151
152
153
154
155
156
157
158
159
160
}

// 全局参数
if (program.debug) global.p_debug = true;
global.ugoiraMeta = program.ugoiraMeta;
global.cf = program.cf;

// 清理 protocol
if (process.platform === 'win32' && (await LoginProtocol.exists())) {
  await LoginProtocol.uninstall();

How to use commander.error:

31
32
33
34
35
36
37
38
39
40
if (commander.name)
  appConf['name']            = commander.name;
if (commander.instances)
  appConf['instances']       = commander.instances;
if (commander.error)
  appConf['error_file']      = commander.error;
if (commander.output)
  appConf['out_file']        = commander.output;
if (commander.pid)
  appConf['pid_file']        = commander.pid;

How to use commander.dir:

39
40
41
42
43
44
45
46
47
48
//}

var mode = program.mode.toLowerCase();
var url = program.url;
var token = program.token;
var datadir = program.dir;
var environment = program.environment ? program.environment : 'test';

var myClients = new Clients(url, token, environment);
var myConnections = new Connections(url, token, environment);

How to use commander.target:

19
20
21
22
23
24
25
start(
    program.bundle,
    program.port || 3000,
    program.host || 'localhost',
    program.displayHost,
    program.target
);

How to use commander.calibre:

36
37
38
39
40
41
42
43
44
45
const device = program.device
const pdf_size = program.size ? getSizeInByte(program.size) : PDF_SIZE
const format = program.format
const white_list = program.whitelist
renderer = program.renderer
calibrePath = program.calibre
if (program.baseUrl) {
  protocol = ''
  baseUrl = program.baseUrl
} else {

How to use commander.cacheid:

73
74
75
76
77
78
79
80
81
82
   program.outputHelp();
   process.exit(1);
}

if (typeof program.cacheid !== 'undefined') {
    cacheId = program.cacheid;
    cache = cacheLib(cacheWriteDir, cacheId);
}

if (typeof program.latency !== 'undefined') {

How to use commander.glob:

31
32
33
34
35
36
37
38
39
40
  cfg = cfg.replace('YOUR_SEMATEXT_LOGS_TOKEN', argv.index)
}
if (argv.glob) {
  if (argv.glob.indexOf('{') === 0) {
    // multiple glob expressions e.g. '{/var/log/**.log,/opt/logs/*.log}'
    var globs = argv.glob.replace(/\{|\}/g, '').split(',')
    var globString = ''
    globs.forEach(function (g, i) {
      if (i === 0) {
        globString = globString + '- ' + g + '\n'

How to use commander.device:

31
32
33
34
35
36
37
38
39
40
  })

program.parse(process.argv)

const title = program.title || inputFolder
const device = program.device
const pdf_size = program.size ? getSizeInByte(program.size) : PDF_SIZE
const format = program.format
const white_list = program.whitelist
renderer = program.renderer

commander functions:

Sorted by popularity