本文整理汇总了TypeScript中yargs.usage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript usage函数的具体用法?TypeScript usage怎么用?TypeScript usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usage函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: gpgMockCli
export function gpgMockCli(args: string[]): void {
const state = GpgMockState.create();
let y = yargs.usage('$0 <cmd> [args]');
y = y.options({
'with-colons': { describe: 'output in colons format', boolean: true },
batch: { describe: 'no interactive processing', boolean: true },
import: { describe: 'import key from stdin', boolean: true },
homedir: { describe: 'the gpg database base directory', type: 'string' },
'passphrase-fd': { describe: 'positional fd inputs', type: 'array' },
version: { describe: 'prints version', boolean: true }
});
state.onParsed(
(_y: yargs.Arguments, _state: GpgMockState): boolean => {
if (_y.version) {
// const version = fs.readFileSync('./')
_state.stdout('gpg-mock (2.1.14)');
return true;
}
return false;
}
);
y = listSecretKeysCli(y, state);
y = fullGenKeyCli(y, state);
y = simpleActionsCli(y, state);
y = agentCli(y, state);
y = cardStatusCli(y, state);
y = y.help().showHelpOnFail(true);
y.parse(args.slice(2), (err: any, argv: yargs.Arguments, output: any) => {
state.parsed(argv);
});
}
示例2: if
function Argv$reset() {
let ya = yargs
.usage('$0 command')
.command('hello', 'hello command')
.command('world', 'world command')
.demand(1, 'must provide a valid command');
let argv = yargs.argv;
let command = argv._[0];
if (command === 'hello') {
ya.reset()
.usage('$0 hello')
.help('h')
.example('$0 hello', 'print the hello message!')
.argv;
console.log('hello!');
} else if (command === 'world') {
ya.reset()
.usage('$0 world')
.help('h')
.example('$0 world', 'print the world message!')
.argv;
console.log('world!');
} else {
ya.showHelp();
}
}
示例3: command
function command() {
var argv = yargs
.usage('npm <command>')
.command('install', 'tis a mighty fine package to install')
.command('publish', 'shiver me timbers, should you be sharing all that', yargs => {
argv = yargs.option('f', {
alias: 'force',
description: 'yar, it usually be a bad idea'
})
.help('help')
.argv;
})
.command("build", "arghh, build it mate", {
tag: {
default: true,
demand: true,
description: "Tag the build, mate!"
},
publish: {
default: false,
description:"Should i publish?"
}
})
.help('help')
.argv;
}
示例4: divide
// Tell users how to use yer options and make demands.
function divide() {
let argv = yargs
.usage('Usage: $0 -x [num] -y [num]')
.demand(['x', 'y'])
.argv;
console.log(argv.x / argv.y);
}
示例5:
function Argv$showHelpOnFail() {
let argv = yargs
.usage('Count the lines in a file.\nUsage: $0')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.showHelpOnFail(false, "Specify --help for available options")
.argv;
}
示例6: line_count
// Yargs is here to help you...
function line_count() {
let argv = yargs
.usage('Count the lines in a file.\nUsage: $0')
.example('$0 -f', 'count the lines in the given file')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.argv
;
}
示例7: readCommandLine
export function readCommandLine(extraOptions?: {[key: string]: any}) {
const options: {[key: string]: any} = {
'bundles': {describe: 'Whether to use the angular bundles or not.', default: false}
};
for (const key in extraOptions) {
options[key] = extraOptions[key];
}
cmdArgs = yargs.usage('Angular e2e test options.').options(options).help('ng-help').wrap(40).argv;
return cmdArgs;
}
示例8: createYargsOption
const main = () => {
const program = yargs
.usage(
"Usage: gulp util:new-language --language-name <language-name> " +
"--language-extension <language-extension> --base-name <base-name>",
)
.option(
"language-name",
createYargsOption({
alias: "n",
describe: "name of the language to add",
}),
)
.option(
"language-extension",
createYargsOption({
alias: "e",
coerce: extensionFormatCheck,
describe: "extension for language files",
}),
)
.option(
"base-name",
createYargsOption({
alias: "b",
describe: "pre-existing language to use as a base",
}),
).argv;
const name = program.languageName;
const extension = program.languageExtension;
const baseName = program.baseName;
const baseExtension = program.baseExtension;
console.log(`Making new language with name '${name}' and extension '${extension}'.`);
console.log(`Basing it off of name '${baseName}' and extension '${baseExtension}'.`);
createNewLanguage(
{
extension,
name,
},
{
extension: baseExtension,
name: baseName,
},
);
};
示例9:
function Argv$usage_as_default_command() {
const argv = yargs
.usage(
"$0 get",
'make a get HTTP request',
(yargs) => {
return yargs.option('u', {
alias: 'url',
describe: 'the URL to make an HTTP request to'
});
},
(argv) => {
console.dir(argv.url);
}
)
.argv;
}