• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript commander.command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中commander.command函数的典型用法代码示例。如果您正苦于以下问题:TypeScript command函数的具体用法?TypeScript command怎么用?TypeScript command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了command函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1:

 return new Promise<void>(async (resolve, reject) => {
   let packageData = await fs.readJson(packagePath);
   commander.version(packageData.version);
   commander.option('--no-headless', 'disables headless mode');
   commander.command('create <url...>')
     .description('creates series metadata')
     .action(exec<string[]>(urls => mio.commands.createAsync(urls).then(resolve, reject)));
   commander.command('download')
     .description('download series')
     .action(exec(() => mio.commands.downloadAsync().then(resolve, reject)));
   commander.command('update <url...>')
     .description('updates series metadata')
     .action(exec<string[]>(urls => mio.commands.updateAsync(urls).then(resolve, reject)));
   commander.parse(argv);
 });
开发者ID:Deathspike,项目名称:mangarack,代码行数:15,代码来源:exec.ts


示例2: versionCommand

 private versionCommand(): void {
   commander
     .command('version')
     .alias('v')
     .description('Shows the CLI-Version')
     .action(async (): Promise<void> => {
       this.version.init();
     });
 }
开发者ID:toxictrash,项目名称:AlegriCLI,代码行数:9,代码来源:index.ts


示例3: helpCommand

 private helpCommand(): void {
   commander
     .command('help')
     .alias('h')
     .description('Help')
     .action(async (): Promise<void> => {
       this.helper.init();
     });
 }
开发者ID:toxictrash,项目名称:AlegriCLI,代码行数:9,代码来源:index.ts


示例4:

Object.keys(tasks).forEach(function(taskName){
	const task = tasks[taskName];
	const {alias,flags,help} = task;
	const command = commander.command(taskName);
	if(alias){
		command.alias(alias);
	}
	if(help){
		command.description(help);
	}
	if(flags && flags.length){
		flags.forEach(function([f,[desc,def]]){
			command.option(f,desc,def);
		})
	}
});
开发者ID:Xananax,项目名称:wpack,代码行数:16,代码来源:wpack.ts


示例5: createCommand

 private createCommand(): void {
   commander
     .command('create')
     .alias('i')
     .description('Creates a Resource from the List')
     .action(async (cmd: any): Promise<void> => {
       this.creater.init().then((resource) => {
         if (resource === 'React') {
           this.creater.react(cmd);
         } else if (resource === 'Angular') {
           this.creater.angular(cmd);
         } else if (resource === 'Vue') {
           this.creater.vue(cmd);
         }
       });
     });
 }
开发者ID:toxictrash,项目名称:AlegriCLI,代码行数:17,代码来源:index.ts


示例6: catch

commands.forEach(command => {

  // create command
  let cmd = program.command(command.name)

  // set alias
  if (command.alias) {
    cmd.alias(command.alias)
  }

  // set usage
  if (command.usage) {
    cmd.usage(command.usage)
  }

  // set description
  if (command.description) {
    cmd.description(command.description)
  }

  // set options
  if (command.options && command.options.length) {
    let options: string[][] = command.options
    options.forEach((option: string[]) => {
      cmd.option(option[0], option[1])
    })
  }

  // set on
  if (_.isObject(command.on)) {
    _.forIn(command.on, (value, key) => {
      cmd.on(key, value)
    })
  }

  // set action
  if (command.action) {
    cmd.action(async (...args) => {
      try {
        await command.action.apply(command, args)
      } catch (err) {
        log.error(err)
      }
    })
  }
})
开发者ID:bbxyard,项目名称:bbxyard,代码行数:46,代码来源:min.ts


示例7: installCommand

 private installCommand(): void {
   commander
     .command('install')
     .alias('i')
     .description('Install a Resource from the List')
     .action(async (): Promise<void> => {
       this.installer.init().then((resource) => {
         if (resource === 'Typescript') {
           this.installer.typescript();
         } else if (resource === 'React') {
           this.installer.react();
         } else if (resource === 'Angular') {
           this.installer.angular();
         } else if (resource === 'Vue') {
           this.installer.vue();
         }
       });
     });
 }
开发者ID:toxictrash,项目名称:AlegriCLI,代码行数:19,代码来源:index.ts


示例8: Conf

const config = new Conf();
let progressBar: ProgressBar<ProgressData>;

interface BinDownloadConfig extends DownloadConfig {
  silent?: boolean;
  limit?: string;
}

// Log any unhandled exceptions...
process.on('uncaughtException', err => log(`uncaughtException: ${err}`, err));
process.on('unhandledRejection', (err, promise) => log(`unhandledRejection: ${err}`, err, promise));

swapArgs('-v', '-V'); // Convert -v to -V so version works correctly...
swapArgs('/?', '-h'); // Convert /? to also show help info...

program
  .command('download <url>').alias('dl')
  .description('Downloads a video from the YouTube link.')
  .option('-p, --preset <preset>', 'The preset format to download.')
  .option('-d, --dir <dir>', 'The location to save the download.')
  .option('-t, --template <template>', 'The format of the the filename, recursively creating missing subfolders.')
  .option('-l, --limit <size>', 'The maximum filesize to download.')
  .option('-s, --silent', 'Hides all output.')
  .action(function (url: string, options: BinDownloadConfig) {
    options.url = url;
    return mergeOptions(options)
      .then((options => {
        return new Pully().download(options);
      }))
      .then((result: DownloadResults) => {
        options.silent || logUpdate(`${chalk.magenta(result.format.data.videoTitle)} saved as
  ${chalk.green(result.path)} [${toHumanTime(result.duration / 1000)}]`);
开发者ID:JimmyBoh,项目名称:pully,代码行数:32,代码来源:pully.ts


示例9: LumberJack

#!/usr/bin/env node
import * as program from 'commander';
import { Translate } from './commands/Translate';
import { Check } from './commands/Check';
import { Update } from './commands/Update';
import { Extract } from './commands/Extract';
import { Convert } from './commands/Convert';
import { LumberJack } from './utils/LumberJack';
const logger = new LumberJack();

program
    .version('0.0.1');

program
    .command('translate [lang]')
    .description('Translate source file to new language')
    .option('-d, --dest <dest>', 'specify localization resources directory.')
    .option('-f, --format <format>', 'specify output format. (json, xliff)')
    .action((...args) => {
        let command: Translate = new Translate();
        command.run(...args);
    });

program
    .command('convert [lang] [to]')
    .description('Convert translations to new format')
    .option('-d, --dest <dest>', 'specify localization resources directory.')
    .option('-f, --format <format>', 'specify output format. (json, namespaced-json, pot, xliff, xliff2)')
    .action((...args) => {
        let command: Convert = new Convert();
        command.run(...args);
开发者ID:bvkimball,项目名称:linguist,代码行数:31,代码来源:cli.ts


示例10:

#!/usr/bin/env node
import * as path     from 'path';
import * as program  from 'commander';
import * as commands from '../commands';

program
  .version(require('../../package.json').version);

program
  .command('create <name>')
  .alias('new')
  .description('create new monogatari')
  .action(commands.create);

program
  .command('play <monogatari>')
  .description('execute monogatari')
  .option('-f, --hostsfile <hostsfile>', 'hosts file', 'hosts.yml')
  .option('-k, --private-key <id_rsa>', 'ssh private key', path.resolve(process.env.HOME, '.ssh/id_rsa'))
  .action(commands.play);

program.parse(process.argv);
开发者ID:waffle-iron,项目名称:shikibu,代码行数:22,代码来源:shikibu.ts



注:本文中的commander.command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript commander.description函数代码示例发布时间:2022-05-25
下一篇:
TypeScript command-line-usage.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap