本文整理汇总了TypeScript中yargs.command函数的典型用法代码示例。如果您正苦于以下问题:TypeScript command函数的具体用法?TypeScript command怎么用?TypeScript command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了command函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: installCommands
export function installCommands() {
const plugins = _(npmPaths())
.filter(existsSync)
.map(listPluggings)
.flatten()
.uniq()
.value() as string[]
let yargs = require('yargs')
const processedCommands = {}
for (const moduleName of ['./cmds', ...plugins]) {
try {
const cmdModule = require(moduleName)
const cmdModules = Array.isArray(cmdModule) ? cmdModule : [cmdModule]
for (const cmd of cmdModules) {
const commandName = cmd.command.split(' ')[0]
if (!processedCommands[commandName]) {
yargs = yargs.command(wrapCommand(cmd))
processedCommands[commandName] = moduleName
} else {
if (processedCommands[commandName] === './cmds') {
console.warn(`${chalk.yellow(
`warning`,
)} command ${commandName} both exists in plugin ${moduleName} and is shipped with the graphql-cli.
The plugin is being ignored.`)
}
}
}
} catch (e) {
console.log(`Can't load ${moduleName} plugin:` + e.stack)
}
}
return yargs
}
开发者ID:koddsson,项目名称:graphql-cli,代码行数:34,代码来源:index.ts
示例2:
function Argv$commandObject() {
let ya = yargs
.command("commandname", "description", {
arg: ({
alias: "string",
array: true,
boolean: true,
choices: [undefined, false, "a", "b", "c"],
coerce: f => JSON.stringify(f),
config: true,
configParser: t => JSON.parse(fs.readFileSync(t, "utf8")),
count: true,
default: "myvalue",
defaultDescription: "description",
demand: true,
demandOption: true,
desc: "desc",
describe: "describe",
description: "description",
global: false,
group: "group",
nargs: 1,
normalize: false,
number: true,
requiresArg: true,
skipValidation: false,
string: true,
type: "string"
} as yargs.Options)
});
}
开发者ID:markusmauch,项目名称:DefinitelyTyped,代码行数:31,代码来源:yargs-tests.ts
示例3:
function Argv$commandObject() {
var ya = yargs
.command("commandname", "description", {
"arg": {
alias: "string",
array: true,
boolean: true,
choices: ["a", "b", "c"],
coerce: f => JSON.stringify(f),
config: true,
configParser: t => t,
count: true,
default: "myvalue",
defaultDescription: "description",
demand: true,
desc: "desc",
describe: "describe",
description: "description",
global: false,
group: "group",
nargs: 1,
normalize: false,
number: true,
requiresArg: true,
skipValidation: false,
string: true,
type: "string"
}
})
}
开发者ID:longlho,项目名称:DefinitelyTyped,代码行数:30,代码来源:yargs-tests.ts
示例4: command
function command() {
let 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 =>
yargs.option('f', {
alias: 'force',
description: 'yar, it usually be a bad idea'
})
.help('help')
)
.command("build", "arghh, build it mate", {
tag: {
default: true,
demand: true,
description: "Tag the build, mate!"
},
publish: {
default: false,
description: "Should i publish?"
}
})
.command({
command: "test",
describe: "test package",
builder: {
mateys: {
demand: false
}
},
handler: (args: any) => {
/* handle me mateys! */
}
})
.command("test", "test mateys", {
handler: (args: any) => {
/* handle me mateys! */
}
})
.help('help')
.argv;
yargs
.command('get', 'make a get HTTP request', (yargs) => {
return yargs.option('url', {
alias: 'u',
default: 'http://yargs.js.org/'
});
})
.help()
.argv;
yargs
.command(
'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);
}
)
.help()
.argv;
}
开发者ID:markusmauch,项目名称:DefinitelyTyped,代码行数:69,代码来源:yargs-tests.ts
示例5:
const versionsIeOption: yargs.Options = {
describe: 'The ie driver version.',
type: 'string'
};
const VERSIONS_STANDALONE = 'versions.standalone';
const versionsStandaloneOption: yargs.Options = {
describe: 'The selenium server standalone version.',
type: 'string'
};
// tslint:disable-next-line:no-unused-expression
yargs
.command(
'clean', 'Removes downloaded files from the out_dir.',
(yargs: yargs.Argv) => {
return yargs.option(LOG_LEVEL, logLevelOption)
.option(OUT_DIR, outDirOption);
},
(argv: yargs.Arguments) => {
clean.handler(argv);
})
.command(
'shutdown', 'Shutdown a local selenium server with GET request',
(yargs: yargs.Argv) => {
return yargs.option(LOG_LEVEL, logLevelOption);
},
(argv: yargs.Arguments) => {
shutdown.handler(argv);
})
.command(
'start', 'Start up the selenium server.',
(yargs: yargs.Argv) => {
开发者ID:angular,项目名称:webdriver-manager,代码行数:32,代码来源:index.ts
示例6: wrap
import chalk from "chalk"
import { getElectronVersion } from "electron-builder-lib/out/util/electronVersion"
import { getGypEnv } from "electron-builder-lib/out/util/yarn"
import { readJson } from "fs-extra-p"
import isCi from "is-ci"
import * as path from "path"
import { loadEnv } from "read-config-file"
import updateNotifier from "update-notifier"
import yargs from "yargs"
import { build, configureBuildCommand } from "../builder"
import { createSelfSignedCert } from "./create-self-signed-cert"
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"
import { start } from "./start"
// tslint:disable:no-unused-expression
yargs
.command(["build", "*"], "Build", configureBuildCommand, wrap(build))
.command("install-app-deps", "Install app deps", configureInstallAppDepsCommand, wrap(installAppDeps))
.command("node-gyp-rebuild", "Rebuild own native code", configureInstallAppDepsCommand /* yes, args the same as for install app deps */, wrap(rebuildAppNativeCode))
.command("create-self-signed-cert", "Create self-signed code signing cert for Windows apps",
yargs => yargs
.option("publisher", {
alias: ["p"],
type: "string",
requiresArg: true,
description: "The publisher name",
})
.demandOption("publisher"),
wrap(argv => createSelfSignedCert(argv.publisher)))
.command("start", "Run application in a development mode using electron-webpack",
yargs => yargs,
wrap(argv => start()))
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:32,代码来源:cli.ts
示例7: loadFactory
main: mainFile
})
}
console.log('Completed!')
process.exit(0)
})
}
export function loadFactory(spec: string) {
let converterFactory: ConverterFactory = require(spec)
if (typeof (converterFactory as any).default !== 'undefined') {
converterFactory = (converterFactory as any).default
}
return converterFactory
}
function defer<T extends Function>(fn: T) {
return (...args: any[]) => {
setTimeout(fn.bind(null, ...args), 0)
}
}
yargs
.command(ReflectCommand)
.command(GenerateCommand)
.strict()
.recommendCommands()
.demandCommand().argv
开发者ID:docscript,项目名称:docscript,代码行数:30,代码来源:cli.ts
示例8: inject
process.exit(1);
};
let failIfUnsuccessful = (success: boolean) => {
if (!success) {
process.exit(1);
}
};
yargsModule.command(['assist', '*'], 'Watches for file changes and outputs current errors and violations', {
port: {
describe: 'the port to have the status server listen on'
}
}, (yargs) => {
if (yargs._.length === 0 || yargs._.length === 1 && yargs._[0] === 'assist') {
inject(createAssistCommand).execute({
statusServerPort: parseInt(yargs.port as string, 10) || 0
});
} else {
console.error('Unknown command');
process.exit(1);
}
});
yargsModule.command(['lint'], 'Lints', {}, yargs => {
inject(createLintCommand).execute().then(onSuccess, onFailure);
});
yargsModule.command(['fix', 'f'], 'Formats changed files and applies tslint fixes', {}, (yargs) => {
inject(createFixCommand).execute().then(onSuccess, onFailure);
});
开发者ID:AFASSoftware,项目名称:typescript-assistant,代码行数:31,代码来源:index.ts
示例9:
function Argv$commandArray() {
let ya = yargs
.command(['commandName', 'commandAlias'], 'command description')
.argv;
}
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:5,代码来源:yargs-tests.ts
注:本文中的yargs.command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论