yargs#usage TypeScript Examples
The following examples show how to use
yargs#usage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: commands.ts From epicgames-freegames-node with MIT License | 6 votes |
{ argv } = usage('$0 <command> [option]')
.command<RedeemArgs>(
['create-account', 'create'],
'Create a fresh account',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(yargs: any) => {
return yargs.usage('$0 create-account').usage('$0 create').help();
},
createAccount
)
.command<RedeemArgs>(
['redeem', 'free-games'],
'Redeem all free games for a user',
(yargs) =>
yargs
.usage('$0 release --username <username> --pasword <password>')
.option('u', {
alias: ['user', 'username'],
type: 'string',
demandOption: false,
})
.option('p', {
alias: ['pass', 'password'],
type: 'string',
demandOption: false,
})
.option('t', {
alias: ['totp', 'mfa'],
type: 'string',
demandOption: false,
})
.help(),
redeemGames
)
.help()
.demandCommand()
Example #2
Source File: index.ts From nestjs-proto-gen-ts with MIT License | 5 votes |
cli = usage('Extract and merge locale files.\nUsage: $0 [options]')
/* eslint-disable @typescript-eslint/no-var-requires */
.version(require(`${__dirname}/../../package.json`).version)
/* eslint-enable @typescript-eslint/no-var-requires */
.alias('version', 'v')
.help('help')
.alias('help', 'h')
.option('path', {
alias: 'p',
describe: 'Path to root directory',
type: 'array',
normalize: true
})
.option('output', {
alias: 'o',
describe: 'Path to output directory',
type: 'string',
normalize: true
})
.option('template', {
describe: "Handlebar's template for output",
type: 'string'
})
.option('target', {
alias: 't',
describe: 'Proto files',
default: options.target,
type: 'array'
})
.option('ignore', {
alias: 'i',
describe: 'Ignore file or directories',
default: options.ignore,
type: 'array'
})
.option('comments', {
alias: 'c',
describe: 'Add comments from proto',
default: options.comments,
type: 'boolean'
})
.option('verbose', {
describe: 'Log all output to console',
default: options.verbose,
type: 'boolean'
})
.demandOption(['path'], red.bold('Please provide both run and [path] argument to work with this tool'))
.exitProcess(true)
.parse(process.argv)