}); }) .check((argv) => { if ('model_id' in argv) { if (!Number.isInteger(argv.model_id)) {
require("yargs") .string("greeting") .check(function(argv) { if (!argv.greeting) { argv.greeting="Default 'Hello, world!' greeting"; } return true; })
require('yargs') .usage('npm run configure -- <arguments>') .describe('p', 'The panel url to pull the configuration from') .alias('p', 'panel-url') .describe('t', 'The configuration token') .alias('t', 'token') .boolean('o') .describe('o', 'Overwrite existing configuration file') .alias('o', 'overwrite') .alias('h', 'help') .check(checkParams) .help('h') .fail((msg, err, yargs) => { console.error(err.message); console.log(yargs.help()); process.exit(1); })
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() .check(args => { const token = jwt.decode(args._[0], {complete: true}); if (!token) {
global: true, }) .check(argv => { const valid = !!(argv.jwtAuthToken || argv.apiKey); if (!valid) {
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()
default: true }) .check(argv => { if (!argv.date && !argv.relativeDate) { return 'Check options. Either provide date, or relative date.'
default: 2 }) .check(argv => { if (argv.firstDate > argv.lastDate) { return `Check --firstDate, --lastDate. Date in --firstDate must be before date in --lastDate.`
}); }) .check((argv) => { if ('model_id' in argv) { if (!Number.isInteger(argv.model_id)) {
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('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()
default: 2 }) .check(argv => { if (argv.firstDate > argv.lastDate) { return `Check --firstDate, --lastDate. Date in --firstDate must be before date in --lastDate.`
default: true }) .check(argv => { if (!argv.date && !argv.relativeDate) { return 'Check options. Either provide date, or relative date.'