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

TypeScript yargs.Argv类代码示例

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

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



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

示例1: Map

	[...commandMap.values()].forEach((command: CommandWrapper) => {
		const { name, register, run } = command;
		let aliases: Aliases = {};
		const groupMap = new Map().set(groupName, commandMap);
		yargs.command(
			name,
			false,
			(optionsYargs: Argv) => {
				register((key: string, options: Options) => {
					aliases = parseAliases(aliases, key, options.alias);
					optionsYargs.option(key, { ...options, ...requireOptions });
				}, helper.sandbox(groupName, name));

				return optionsYargs.showHelpOnFail(false, formatHelp({ _: [groupName, name] }, groupMap)).strict();
			},
			async (argv: any) => {
				if (argv.h || argv.help) {
					console.log(formatHelp(argv, groupMap));
					return Promise.resolve({});
				}

				const config = helper.sandbox(groupName, name).configuration.get();
				const args = getOptions(aliases, config, argv);

				if (typeof command.validate === 'function') {
					const valid = await command.validate(helper.sandbox(groupName, command.name));
					if (!valid) {
						return;
					}
				}
				return run(helper.sandbox(groupName, name), args).catch(reportError);
			}
		);
	});
开发者ID:dojo,项目名称:cli,代码行数:34,代码来源:registerCommands.ts


示例2: parseAliases

			(optionsYargs: Argv) => {
				register((key: string, options: Options) => {
					aliases = parseAliases(aliases, key, options.alias);
					optionsYargs.option(key, { ...options, ...requireOptions });
				}, helper.sandbox(groupName, name));

				return optionsYargs.showHelpOnFail(false, formatHelp({ _: [groupName, name] }, groupMap)).strict();
			},
开发者ID:dojo,项目名称:cli,代码行数:8,代码来源:registerCommands.ts


示例3: registerGroups

function registerGroups(yargs: Argv, helper: HelperFactory, groupName: string, commandMap: CommandMap): void {
	const groupMap = new Map().set(groupName, commandMap);
	const defaultCommand = getCommand(groupMap, groupName);
	let aliases: Aliases = {};
	yargs.command(
		groupName,
		false,
		(subYargs: Argv) => {
			defaultCommand.register((key: string, options: Options) => {
				aliases = parseAliases(aliases, key, options.alias);
				subYargs.option(key, { ...options, ...requireOptions });
			}, helper.sandbox(groupName, defaultCommand.name));

			registerCommands(subYargs, helper, groupName, commandMap);
			return subYargs
				.option('h', {
					alias: 'help'
				})
				.showHelpOnFail(false, formatHelp({ _: [groupName] }, groupMap))
				.strict();
		},
		async (argv: any) => {
			if (defaultCommand && argv._.length === 1) {
				if (argv.h || argv.help) {
					console.log(formatHelp(argv, groupMap));
					return Promise.resolve({});
				}
				const config = helper.sandbox(groupName, defaultCommand.name).configuration.get();
				const args = getOptions(aliases, config, argv);

				if (typeof defaultCommand.validate === 'function') {
					const valid = await defaultCommand.validate(helper.sandbox(groupName, defaultCommand.name));
					if (!valid) {
						return;
					}
				}
				return defaultCommand.run(helper.sandbox(groupName, defaultCommand.name), args).catch(reportError);
			}
		}
	);
}
开发者ID:dojo,项目名称:cli,代码行数:41,代码来源:registerCommands.ts


示例4: function

module.exports = function(yargs: Argv) {
  yargs.command('cluster', 'Check your clusters', function(
    yargsCluster: Argv,
  ): Argv {
    const configFile = process.env.HOME + '/.kube/config';

    if (!fs.existsSync(configFile)) {
      return;
    }

    const kc = new k8s.KubeConfig();
    kc.loadFromFile(configFile);

    const k8sApiCore = new k8s.Core_v1Api(kc.getCurrentCluster().server);
    const k8sApiApps = new k8s.Apps_v1beta1Api(kc.getCurrentCluster().server);
    k8sApiCore.setDefaultAuthentication(kc);
    k8sApiApps.setDefaultAuthentication(kc);

    k8sApiApps
      .createNamespacedStatefulSet('default', loadState('mongodb'))
      .then(function(value) {
        console.log(value);
        return;
      })
      .catch(function(err) {
        console.error(err);
      });

    function loadState(name: string): V1beta2StatefulSet {
      const state = new k8s.V1beta2StatefulSet();
      const file = path.join(__dirname, 'stateful-set', `${name}.yml`);
      const data = yaml.safeLoad(fs.readFileSync(file, 'utf8'));
      _.extend(state, data);
      return state;
    }

    return;
  });
};
开发者ID:agneta,项目名称:platform,代码行数:39,代码来源:index.ts


示例5: Error

> /* istanbul ignore next */ = (
  yargs: Argv<PwArgvOptions>,
): Argv<PwHandlerOptions> =>
  yargs
    .positional('password', {
      type: 'string',
    })
    .demand('password')
    .check(argv => {
      if (!argv.password.length) {
        throw new Error('The password argument must not be empty.');
      }
      return true;
    })
    .option('r', {
      alias: 'raw',
      describe: 'disable the console spinner',
      type: 'boolean',
      default: false,
    })
    .group(['r'], 'Command Options:')
    .group(['h', 'v'], 'Global Options:');
开发者ID:wKovacs64,项目名称:pwned,代码行数:22,代码来源:pw.ts


示例6: function

export default function(yargs: Argv, groupMap: GroupMap): void {
	const helperContext = {};
	const commandHelper = new CommandHelper(groupMap, helperContext, configurationHelperFactory);
	const validateHelper = { validate: builtInCommandValidation }; // Provide the default validation helper
	const helperFactory = new HelperFactory(
		commandHelper,
		yargs,
		helperContext,
		configurationHelperFactory,
		validateHelper
	);

	groupMap.forEach((commandMap, group) => {
		registerGroups(yargs, helperFactory, group, commandMap);
	});

	yargs
		.demand(1, '')
		.command(
			'$0',
			false,
			(dojoYargs: Argv) => {
				dojoYargs.option('h', {
					alias: 'help'
				});
				return dojoYargs;
			},
			(argv: any) => {
				console.log(formatHelp(argv, groupMap));
			}
		)
		.check(createOptionValidator(groupMap), true)
		.help(false)
		.showHelpOnFail(false)
		.strict().argv;
}
开发者ID:dojo,项目名称:cli,代码行数:36,代码来源:registerCommands.ts


示例7:

			(dojoYargs: Argv) => {
				dojoYargs.option('h', {
					alias: 'help'
				});
				return dojoYargs;
			},
开发者ID:dojo,项目名称:cli,代码行数:6,代码来源:registerCommands.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript yargs-parser.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript yargs.wrap函数代码示例发布时间: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