/** * Returns a parsed array of CLI arguments and options * * @since 3.0.0 * @alias lando.cli.argv * @return {Object} Yarg parsed options * @example * const argv = lando.cli.argv(); * @todo make this static and then fix all call sites */ argv() { return require('yargs').help(false).version(false).argv; }
// eslint-disable-next-line const run = () => yargs .version(cliVersion) .commandDir(COMMAND_DIR) .demandCommand() .help() .argv
yargs .option('indices', { alias: ['i', 'index'], array: true, choices: mappings.list.map(({ name }) => name) }) .option('switch', { alias: 's', boolean: true, default: true }) .option('inserts', { boolean: true, default: true }) .option('flush', { boolean: true, default: false }) .help() .version()
function init (data) { if (data && semver.gt(data.version, version)) { console.log(chalk.red(`------ You're running gloria in version ${version}, the latest version is ${data.version}. Run 'npm install -g gloria' to get the latest version ------`)); } // Using yargs to identify commands and arguments // https://www.npmjs.com/package/yargs require(`yargs`) .commandDir(`../commands`) .alias('v', 'version') .version(require(`../version`)) .help() .usage(`Gloria is a static site generator. Use the command init to get started.`) .epilogue(`For more information, check out the documentation in github.com/gloriajs/gloria`) .argv; }
function getYargsParser() { return yargs .help() .alias("h", "help") .updateStrings({ 'Positionals:': 'Arguments:', 'Not enough non-option arguments: got %s, need at least %s': "Error: Missing argument <action> (%s/%s)" }) .version(false) .wrap(90) .command( "* <action> [source-path]", `Debug an OpenWhisk <action> by forwarding its activations to a local docker container that has debugging enabled and its debug port exposed to the host. If only <action> is specified, the deployed action code is debugged. If [source-path] is set, it must point to the local action sources which will be mounted into the debug container. Sources will be automatically reloaded on each new activation. This feature depends on the kind. Supported kinds: - ${getSupportedKinds().join("\n")} `, yargsOptions ); }
.default('start', 0) .help() .version() .check(args => { const token = jwt.decode(args._[0], {complete: true});
yargs .option('campaign', { alias: ['c', 'ac', 'accessCampaignId'] }) .option('granter', { alias: ['g', 'u', 'user'] }) .option('amount', { alias: ['n'], type: 'number', default: 1 }) .option('prefix', { alias: ['p'] }) .default(['campaign', 'granter', 'label']) .check(argv => { if (argv.prefix && argv.prefix.length >= grantsLib.VOUCHER_CODE_LENGTH) { return `Check --prefix. "${argv.prefix}" too long to generate voucher codes.` } if (argv.prefix && argv.prefix.match(/[^123456789ABCDEFGHKLMRSTUWXYZ]+/)) { return `Check --prefix. "${argv.prefix}" contains invalid chars.` } if (argv.amount < 1) { return `Check --amount. Should be at least 1.` } return true }) .help() .version()
}) .help() .version()
yargs .option('types', { type: 'array', default: [] }) .option('limit', { default: 1000 }) .option('dry-run', { default: true }) .check(argv => { if (argv.types.length === 0) { return 'Check --types. Should contain at least one type.' } return true }) .help() .version()
}) .help() .version()
yargs .option('types', { type: 'array', default: [] }) .option('limit', { default: 1000 }) .option('dry-run', { default: true }) .check(argv => { if (argv.types.length === 0) { return 'Check --types. Should contain at least one type.' } return true }) .help() .version()
yargs .option('indices', { alias: ['i', 'index'], array: true, choices: mappings.list.map(({ name }) => name) }) .option('switch', { alias: 's', boolean: true, default: true }) .option('inserts', { boolean: true, default: true }) .option('flush', { boolean: true, default: false }) .help() .version()
yargs .option('campaign', { alias: ['c', 'ac', 'accessCampaignId'] }) .option('granter', { alias: ['g', 'u', 'user'] }) .option('amount', { alias: ['n'], type: 'number', default: 1 }) .option('prefix', { alias: ['p'] }) .default(['campaign', 'granter', 'label']) .check(argv => { if (argv.prefix && argv.prefix.length >= grantsLib.VOUCHER_CODE_LENGTH) { return `Check --prefix. "${argv.prefix}" too long to generate voucher codes.` } if (argv.prefix && argv.prefix.match(/[^123456789ABCDEFGHKLMRSTUWXYZ]+/)) { return `Check --prefix. "${argv.prefix}" contains invalid chars.` } if (argv.amount < 1) { return `Check --amount. Should be at least 1.` } return true }) .help() .version()
}) .help() .version()