How to use the option function from yargs
Find comprehensive JavaScript yargs.option code examples handpicked from public code repositorys.
GitHub: EYBlockchain/nightfall
2 3 4 5 6 7 8 9 10 11
* and it's a bit of a pain to look up the NIST standard and manually compute it * each time */ const yargs = require('yargs'); const options = yargs.option('l', { alias: 'message-length', describe: 'the length of the message to be padded in bits', type: 'number', demandOption: true,
159
862
58
+ 13 other calls in file
GitHub: Journaly/journaly
63 64 65 66 67 68 69 70 71 72
.scriptName('jadmin') .command({ command: 'delete-user <userId>', describe: 'Hard delete a user and related records', builder: (yargs) => { yargs.option('force', { describe: 'Bypass interactive safety checks', type: 'boolean', }) yargs.option('database-url', {
18
45
7
+ 15 other calls in file
GitHub: figassis/wildduck
114 115 116 117 118 119 120 121 122 123
) .command( 'clear <user>', 'Delete all tokens for a user', yargs => yargs.option('user', { alias: 'u', describe: 'User to de-provision', demandOption: true }),
245
3
1
+ 11 other calls in file
15 16 17 18 19 20 21 22 23 24
// add it below, and move src/index.html to src/common/index.html. const APPS = ['public']; // webpack v5 no longer passes command line flags so hooking into // "name" flag instead of "app". const argv = yargs.option('name', { array: true, alias: 'apps', default: APPS, }).argv;
15
196
9
210 211 212 213 214 215 216 217 218 219
/* Register command line arguments */ yargs.command('*', false, (yargs: any) => { common_args.add_universal_arguments(yargs); common_args.add_common_mqtt_arguments(yargs); common_args.add_direct_tls_connect_arguments(yargs); yargs.option('count', { description: '<number>: The number of messages to publish (optional, default=10)', type: 'int', required: false, default: 10
96
170
21
+ 11 other calls in file
GitHub: katat/vbot
50 51 52 53 54 55 56 57 58 59
let vbotOpts = {verbose: true} Object.keys(this.cmdOptions).forEach((opt) => { if(!this.cmdOptions[opt].show) { return; } yargs.option(opt, this.cmdOptions[opt]) }); yargs .usage('vbot <-f> | vbot download <--client-key> <--scenario-id>') .command('$0', 'run vbot test from local json file', (yargs) => {
10
94
5
+ 3 other calls in file
GitHub: MGMonge/petrol
84 85 86 87 88 89 90 91 92 93
console.log(failures); }) }) .command('make:test [name]', 'Create a test', (yargs) => { yargs.option('for', { describe: 'Create a testcase for a specific framework. The default is a framework agnostic TestCase', default: 'default', choices: ['default', 'vue'] })
2
15
2
+ 3 other calls in file
4 5 6 7 8 9 10 11 12 13
const yargs = require('yargs'); const execSync = require('./exec-sync'); const { findGitRoot } = require('./monorepo/index'); const chalk = require('chalk'); const options = yargs.option('webpackConfig', { alias: 'w', type: 'string' }).argv; const webpackConfigFilePath = options.webpackConfig || 'webpack.codepen.config.js'; const configPath = path.resolve(process.cwd(), webpackConfigFilePath);
0
1
0
115 116 117 118 119 120 121 122 123 124
} }) Object.keys(spec.properties).forEach(propertyKey => { const property = spec.properties[propertyKey] yargs.option(propertyKey, { type: property.type, describe: property.description, default: property.default, group: 'Preset Configuration:'
808
0
1
GitHub: merlox/casino-ethereum
0 1 2 3 4 5 6 7 8 9
const express = require('express') const bodyParser = require('body-parser') const { join } = require('path') const app = express() const yargs = require('yargs') const argv = yargs.option('port', { alias: 'p', description: 'Set the port to run this server on', type: 'number', }).help().alias('help', 'h').argv
155
201
12
6 7 8 9 10 11 12 13 14
const fileNameLatest = `openapi-cli.latest.tar.gz`; execSync(`tar -zcvf ${fileName} dist`); execSync(`tar -zcvf ${fileNameLatest} dist`); const argv = yargs.option('aws-profile', { alias: 'p', type: 'string', }).argv;
83
560
28
27 28 29 30 31 32 33 34 35 36 37 38
const yargs = require('yargs'); const { computeVersion, resolveVscodeVersion, isPublished } = require('./version'); const { dist, extensions, theiaExtension } = require('./paths.js'); const { tag, force } = yargs.option('tag', { choices: ['latest', 'next'] }).demandOption('tag') .option('force', { description: 'Create extension pack even if it is found to be already available',
32
58
15
GitHub: himerus/outline
6 7 8 9 10 11 12 13 14
const fs = require('fs'); const glob = require('glob'); const outline = require('../outline.config'); const config = require('@phase2/outline-config/postcss.config'); const options = yargs.option('watch', { type: 'boolean', describe: 'Watch the file system for changes and render automatically', }).argv;
25
0
1
+ 7 other calls in file
GitHub: dockerizeme/dockerizeme
32 33 34 35 36 37 38 39 40
yargs.option('cmd', { type: 'string', describe: 'CMD executable for the final Dockerfile.' }); yargs.option('arg', { type: 'array', describe: 'CMD arguments for the final Dockerfile.' });
18
24
2
+ 11 other calls in file
GitHub: mikeal/daily
71 72 73 74 75 76 77 78 79 80
const style = fs.readFileSync(__dirname + '/email-style.css').toString() const html = juice(`<style>${style}</style>${converter.makeHtml(stripCharts(readme))}`) await mailchimp(title, html) } const outputOptions = yargs => { yargs.option('output', { alias: 'o', description: 'Output file or directory.' }) }
6
262
0
+ 5 other calls in file
GitHub: 2003scape/rsc-sprites
56 57 58 59 60 61 62 63 64 65
'manually specify the archive type (entity, ' + 'media or textures)', type: 'string' }); yargs.option('merge', { alias: 'm', description: 'also dump textures that rely on two textures', type: 'boolean' });
4
6
3
+ 5 other calls in file
GitHub: quantcdn/quant-cli
46 47 48 49 50 51 52 53 54 55
describe: 'Skip the automatic cache purge process', alias: 'sp', type: 'boolean', default: false, }); yargs.option('chunk-size', { describe: 'Control the chunk-size for concurrency', alias: 'cs', type: 'integer', default: 10,
0
2
3
+ 3 other calls in file
65 66 67 68 69 70 71 72 73 74 75
if (showdownOptions[opt].defaultValue === false) { showdownOptions[opt].default = null; } else { showdownOptions[opt].default = showdownOptions[opt].defaultValue; } yargs.option(opt, showdownOptions[opt]); } } function run () {
0
0
1
+ 13 other calls in file
GitHub: wedik66/Acorn
14 15 16 17 18 19 20 21 22 23 24
.replace(/[^a-z]+/g, '-') .replace(/(^-|-$)/g, '') ])); parserNames.forEach(name => { yargs.option(optionNames.get(name), { group: 'Benchmark parsers:', describe: name, type: 'boolean', default: name.startsWith('Acorn') || undefined
0
0
1
+ 4 other calls in file
9 10 11 12 13 14 15 16 17 18
.command( "solve <challenge>", "Solve the given challenge with the given solution and input " + "or all of them if none is given", (yargs) => { yargs.option("challenge", { describe: "The challenge name", type: "string", demandOption: true, // This argument is required });
0
0
0
yargs.argv is the most popular function in yargs (1012 examples)