本文整理汇总了TypeScript中commander.name函数的典型用法代码示例。如果您正苦于以下问题:TypeScript name函数的具体用法?TypeScript name怎么用?TypeScript name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了name函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
.on('--help', function () {
console.log(' Examples:');
console.log();
console.log(` $ ${program.name()} --indir def/model --outdir src/model`);
console.log(` $ ${program.name()} --indir def/model --outdir src/model --id php:ver=5;def=true,cs:ident=2`);
console.log(` $ ${program.name()} --indir def/model --outdir src/model --id php:ver=5;def=true,cs:ident=2 --template-path user_template`);
console.log(` $ ${program.name()} list --template-path user_template`);
console.log(` $ ${program.name()} init new_project`);
console.log();
});
示例2:
.action(function (dir, options) {
let sdir = dir;
dir = cmd.emptydir(dir);
fs.copySync(path.join(Setting.test_items_dir, 'example'), dir);
fs.removeSync(path.join(dir,'__check__'));
console.log(`Project successfully created.`);
console.log(`To use: '${program.name()} --indir ${sdir} --outdir <outdir>'`);
console.log(`We recommend add in a file 'package.json' => script: {"build-mcgen": "${program.name()} --indir ${sdir} --outdir <outdir>"}`);
process.exit(0);
});
示例3: require
#!/usr/bin/env node
var program = require("commander");
/**
* Define command line argv
*/
program
.version("0.0.1")
.option("-p, --port <port>", "Server IP port", parseInt,9000)
.parse(process.argv);
console.log('Start %s on port : %j', program.name(), program.port);
示例4: range
import * as program from 'commander';
interface ExtendedOptions extends program.CommandOptions {
isNew: any;
}
const commandInstance = new program.Command('-f');
const optionsInstance = new program.Option('-f');
const name = program.name();
program
.name('set name')
.version('0.0.1')
.option('-p, --peppers', 'Add peppers')
.option('-P, --pineapple', 'Add pineapple')
.option('-b, --bbq', 'Add bbq sauce')
.option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
.parse(process.argv);
console.log('you ordered a pizza with:');
if (program['peppers']) console.log(' - peppers');
if (program['pineapple']) console.log(' - pineapple');
if (program['bbq']) console.log(' - bbq');
console.log(' - %s cheese', program['cheese']);
function range(val: string) {
return val.split('..').map(Number);
}
function list(val: string) {