How to use the usage function from yargs
Find comprehensive JavaScript yargs.usage code examples handpicked from public code repositorys.
17 18 19 20 21 22 23 24 25 26
//app.setAppUserModelId("app."+Date.now()); var ver = app.getVersion(); function createYargs(){ var argv = Yargs.usage("Usage: $0 -w num -h num -w string -p") .example( "$0 -w 1280 -h 720 -u https://vdo.ninja/?view=xxxx", "Loads the stream with ID xxxx into a window sized 1280x720" )
29
265
17
12 13 14 15 16 17 18 19 20 21
// The relative path is '../../util/cli_args' from here, but the compiled javascript file gets put one level // deeper inside the 'dist' folder const common_args = require('../../../util/cli_args'); yargs.command('*', false, (yargs: any) => { yargs.usage("Connect using using a private key stored on a PKCS#11 device."); common_args.add_universal_arguments(yargs); common_args.add_common_mqtt_arguments(yargs); yargs
96
172
21
+ 7 other calls in file
70 71 72 73 74 75 76 77 78 79
// running in TTY mode, get template from non-positional argument yargs .usage('Usage: mgeneratejs <options> [template]') .demand(1, 'must provide a template file or string'); } else { yargs.usage('Usage: mgeneratejs <options> < [template]'); } var argv = yargs.argv; var template;
21
116
3
0 1 2 3 4 5 6 7 8 9
#!/usr/bin/env node const Yargs = require('yargs'); const supertiler = require('./index.js'); const argv = Yargs.usage('Usage: $0 [options]') .example('$0 -i in.geojson -o out.mbtiles --minZoom 0 --maxZoom 5 --map "(props) => ({sum: props.myValue})" --reduce "(accumulated, props) => { accumulated.sum += props.sum; }"', 'Cluster from zoom 0 to 5 while aggregating "myValue" into "sum" property. Outputs tileset with zoom from 0 to 6.') .alias('input', 'i') .nargs('input', 1)
6
70
3
GitHub: vmware/vcd-ext-sdk
0 1 2 3 4 5 6 7 8 9
const Ccss = require('clean-css') const fs = require('fs') const sass = require('node-sass') const args = require('yargs') const argv = args.usage('$0 [options]', 'Generates a CSS file with specified overrides applied to base Clarity styles') .options({ 'theme': { alias: 't', demandOption: true,
42
42
20
1 2 3 4 5 6 7 8 9 10
const debug = require('debug')(meta.name + ':command') const yargs = require('yargs') module.exports = () => { yargs.usage('Usage: $0 <command> [options]') yargs.options({ 'url': { alias: 'u', nargs: 1,
13
30
4
27 28 29 30 31 32 33 34 35
.style('yellow', 'required') .helpStyle('green') .errorsStyle('red') ; cli.usage(`Usage: $0 <command> [options]`); this.commands.forEach((command) => { cli.command(command); });
2
20
5
1 2 3 4 5 6 7 8 9 10
const fs = require('fs'); const exec = require('child_process').exec; const yargs = require('yargs'); const options = yargs.usage('Usage: -n <name>').options({ n: { alias: 'name', describe: 'Project name', type: 'string',
0
3
1
+ 11 other calls in file
GitHub: mpeglerg/Inkling
44 45 46 47 48 49 50 51 52 53
} // If running as a script, we have a lot of command line processing to do. The source // program will come from the file name that is given as the command line argument. if (require.main === module) { const { argv } = yargs.usage('$0 [-a] [-o] [-i] filename') .boolean(['a', 'o', 'i']) .describe('a', 'show abstract syntax tree after parsing then stop') .describe('o', 'do optimizations') .describe(
5
2
5
GitHub: patrickhulce/lint
2 3 4 5 6 7 8 9 10
const fs = require('fs') const path = require('path') const yargs = require('yargs') const execSync = require('child_process').execSync const argv = yargs.usage('Usage: $0 [options]').option('fix', { describe: 'auto-fix problems', type: 'boolean', }).argv
0
1
2
GitHub: Trustroots/trustroots
14 15 16 17 18 19 20 21 22 23
require('../../modules/offers/server/models/offer.server.model'); /** * Configure the script usage using yargs to obtain parameters and enforce usage. */ const argv = yargs.usage( '$0 <numberOfUsers>', 'Seed database with number of tribes', function (yargs) { return yargs
142
380
30
+ 3 other calls in file
209 210 211 212 213 214 215 216 217 218
} } return numFailures; }; var opts = yargs.usage('Usage: $0 [--timingMode [--iterationCount N]] [--log] --transformer NAME --inputFile /path/filename', { help: { description: [ 'domTest.js supports parsoid generated test validation.', 'The --timingMode flag disables console output and',
51
0
1
168 169 170 171 172 173 174 175 176 177
set options(opt) { this.yargs.options(opt); } /** * shortcut for yargs.usage * @param {String} usage - usage info */ set usage(usage) { this.yargs.usage(usage);
23
189
17
GitHub: lando/cli
456 457 458 459 460 461 462 463 464 465
const suffix = this.app ? `(${this.app.name}, v4)` : '(v4)'; const cmd = !this.product.config.get('system.packaged') ? '$0' : path.basename(get(process, 'execPath', 'lando')); const usage = [`Usage: ${cmd} <command> [args] [options] | ${chalk.magenta(suffix)}`]; // Yargs! yargs.usage(usage.join(' ')) .example(`${this.id} start`, 'starts up the app in cwd') .example(`${this.id} rebuild --help`, 'displays help about the rebuild command') .example(`${this.id} destroy -y --debug`, 'runs destroy non-interactively and with debug output') .example(`${this.id} --no-cache`, 'disables and wipes cache')
35
31
0
+ 3 other calls in file
3 4 5 6 7 8 9 10 11 12
const index = require('../buildindex.js'); const path = require('path'); const yargs = require('yargs'); const ARGS = yargs.usage('$0 input.js\nSee README.md for input requirements.') .alias('d', 'debug') .boolean('d') .demand(1) .wrap(80)
5
3
15
209 210 211 212 213 214 215 216 217 218 219
return templatePathParameter === PASSWORD_TEMPLATE_DEFAULT_PATH; } exports.isCustomPasswordTemplateDefault = isCustomPasswordTemplateDefault; function parseCommandLineArguments() { return Yargs.usage("Usage: staticrypt <filename> [<password>] [options]") .option("c", { alias: "config", type: "string", describe: 'Path to the config file. Set to "false" to disable.',
364
0
54
+ 9 other calls in file
282 283 284 285 286 287 288 289 290 291 292
return templatePathParameter === PASSWORD_TEMPLATE_DEFAULT_PATH; } exports.isCustomPasswordTemplateDefault = isCustomPasswordTemplateDefault; function parseCommandLineArguments() { return Yargs.usage("Usage: staticrypt <filename> [options]") .option("c", { alias: "config", type: "string", describe: 'Path to the config file. Set to "false" to disable.',
364
0
53
+ 17 other calls in file
GitHub: datagir/nosgestesclimat
78 79 80 81 82 83 84 85 86 87 88 89
// TODO: // - switch to typescript in order to specify the type of opts // - could be cleaner const getArgs = (description, opts) => { let args = yargs.usage(`${description}\n\nUsage: node $0 [options]`) if (opts.source) { args = args.option('source', { alias: 's',
54
121
5
+ 18 other calls in file
22 23 24 25 26 27 28 29 30 31 32 33 34 35
app.use(express.static('public')); const usageSTR = "\nUsage: todo <command> <options>"; use = yargs.usage(usageSTR); const commands = yargs.command("create", "Ajoute une todo", (y) => { y.option('t', { alias: "task", describe: "Tache à rappeler", type: "string", demandOption: true }); y.option('c', { alias: "complete", describe: "Si la tâche est terminer", type: "string", demandOption: false });
0
0
1
+ 24 other calls in file
GitHub: BeyondTest1/testack
34 35 36 37 38 39 40 41 42 43
const yargs = require('yargs'); const inquirer = require('inquirer'); const { install, setRootDir } = require('lmify'); const usage = "\nUsage: testack -n <name> -t <template> -d <databases> -b <brokers> \nExecute microservices tests\n"; const config = new configstore_1.default('testack', {}, { globalConfigPath: true }); const options = yargs.usage(usage) .option("n", { alias: "name", describe: "what is your project name", type: "string", demandOption: false }) .option("t", { alias: "template", describe: "which language you'ld like to use", type: "string", demandOption: false }) .option("d", { alias: "databases", describe: "which databases are used?", type: "array", demandOption: false }) .option("b", { alias: "brokers", describe: "which brokers are used?", type: "array", demandOption: false })
0
0
1
+ 3 other calls in file
yargs.argv is the most popular function in yargs (1012 examples)