本文整理汇总了TypeScript中cli.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: if
cli.output(line + sep);
} else if (cli.args.length) {
output_file(cli.args.shift());
}
});
};
if (cli.args.length) {
output_file(cli.args.shift());
}
// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/command.js
// ============================================================================
cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);
console.log('Command is: ' + cli.command);
// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/echo.js
// ============================================================================
cli.parse({
newline: ['n', 'Do not output the trailing newline'],
escape: ['e', 'Enable interpretation of backslash escapes'],
separator: ['s', 'Separate arguments using this value', 'string', ' '],
output: [false, 'Write to FILE rather than the console', 'file']
});
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:30,代码来源:cli-tests.ts
示例2: require
build,
} from './main';
import * as log from './log';
cli.enable('version');
const pkg = require(path.join(pkgDir.sync(__dirname), 'package.json'));
cli.parse({
project: ['p', 'Project file', 'path'],
outDir: ['o', 'Output directory', 'path'],
force: ['f', 'Force all files to be re-rendered'],
nobuild: [null, 'Disable startup building.'],
watch: ['w', 'Watch'],
server: ['s', 'Enable web server for testing.'],
port: [null, 'Port number of web server.', 'number'],
// logs
quiet: ['q', 'Quiet logs'],
verbose: [null, 'Verbose logs'],
});
cli.main((args, options)=>{
if (options.quiet){
log.setLogLevel(log.LogLevel.error);
}
if (options.verbose){
log.setLogLevel(log.LogLevel.verbose);
}
开发者ID:uhyo,项目名称:my-static,代码行数:30,代码来源:bin.ts
示例3: require
import build_drives = require('./build-drives');
import path = require('path');
import fs = require('fs');
var cli = require('cli');
var log = require('./log');
var commands = [
'layer',
'bundle',
'server'
];
cli.parse({
file: ['f', 'portable.js config file location', 'string'],
verbose: ['v', 'Aggressively print logs to console'],
debug: ['', 'Output debug info'],
}, commands);
cli.main(function(args, options) {
try {
if(cli.command) {
if(commands.indexOf(cli.command) < 0) throw Error('Invalid command: ' + cli.command);
// First try to run the `portable-js` package that is installed in folder where manifest file is located,
// if not found, run the command from the global package.
var manifest_dir = '';
if(options.file) {
manifest_dir = path.dirname(options.file);
} else {
manifest_dir = process.cwd();
开发者ID:streamich,项目名称:portable,代码行数:31,代码来源:cli.ts
示例4: require
new_argv.push(value);
} else {
new_argv.push(arg);
}
}
process.argv = new_argv;
}
var cli = require('cli');
cli.parse({
"config-file": ['', 'Configuration file', "string"],
config: ['', 'Configuration as JSON string', "string"],
code: ["c", "Code to evaluate", "string"],
port: ["p", "TCP port or UNIX socket file", "string"],
ssh: ["", "SSH host", "string"],
client: ["", "Connect to a jssh server", "bool"],
stdio: ["s", "Communicate through STDIO", "bool"],
});
cli.main(function(args, options) {
//console.log(args, options);
var file_arg_pos = 0; // Position of a file to include in arguments list.
if(options['config-file']) {
var path = require('path');
var conffile = path.resolve(options['config-file']);
try {
var json = fs.readFileSync(conffile);
开发者ID:streamich,项目名称:jssh,代码行数:31,代码来源:cli.ts
注:本文中的cli.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论