当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript yargs-parser.default函数代码示例

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


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

示例1: registerSlashCommand

  registerSlashCommand('joinWarband', 'Join an existing Warband.', (args: string) => {
    let argv = yargs(args);
    if (argv._.length === 1) {
      // name only

      webAPI.warbands.joinWarbandByName(client.shardID, argv._[0], client.characterID)
        .then((response: any) => {
          if (!response.ok) {
            // something went wrong
            console.error(response);
            return;
          }
          // success
        });

    } else if (argv._.length === 2) {
      // name and invite code

      webAPI.warbands.joinWarbandByName(client.shardID, argv._[0], client.characterID, argv._[1])
        .then((response: any) => {
          if (!response.ok) {
            // something went wrong
            console.error(response);
            return;
          }
          // success
        });

    } else {
      systemMessage('Please provide a Warband name, or a Warband name and invite code in order to join a Warband.');
    }
  });
开发者ID:Shane7,项目名称:Camelot-Unchained,代码行数:32,代码来源:slashCommands.ts

示例2: parseChromeFlags

export function parseChromeFlags(flags: string = '') {
  const parsed = yargsParser(
      flags, {configuration: {'camel-case-expansion': false, 'boolean-negation': false}});

  return Object
      .keys(parsed)
      // Remove unnecessary _ item provided by yargs,
      .filter(key => key !== '_')
      // Avoid '=true', then reintroduce quotes
      .map(key => {
        if (parsed[key] === true) return `--${key}`;
        return `--${key}="${parsed[key]}"`;
      });
}
开发者ID:manekinekko,项目名称:lighthouse,代码行数:14,代码来源:run.ts

示例3: main

async function main(): Promise<void> {
  const args = parseArgs(process.argv.slice(2), {boolean: ["profile"]});
  const projectPath = args._[0];
  const shouldProfile = args.profile;
  const numTimes = args.times || 1;

  const projectFiles = await loadProjectFiles(projectPath);
  if (numTimes === 1) {
    console.log(`Running Sucrase on ${projectPath}`);
  } else {
    console.log(`Running Sucrase ${numTimes} times on ${projectPath}`);
  }
  const totalLines = projectFiles
    .map(({code}) => code.split("\n").length)
    .reduce((a, b) => a + b, 0);
  console.log(`Found ${projectFiles.length} files with ${totalLines} lines`);

  if (shouldProfile) {
    console.log(`Make sure you have Chrome DevTools for Node open.`);
    // tslint:disable-next-line no-any
    (console as any).profile(`Sucrase ${projectPath}`);
    for (let i = 0; i < numTimes; i++) {
      for (const fileInfo of projectFiles) {
        runTransform(fileInfo);
      }
    }
    // tslint:disable-next-line no-any
    (console as any).profileEnd(`Sucrase ${projectPath}`);
  } else {
    const startTime = process.hrtime();
    for (let i = 0; i < numTimes; i++) {
      for (const fileInfo of projectFiles) {
        runTransform(fileInfo);
      }
    }
    const totalTime = process.hrtime(startTime);
    const timeSeconds = totalTime[0] + totalTime[1] / 1e9;
    console.log(`Time taken: ${Math.round(timeSeconds * 1000) / 1000}s`);
    console.log(`Speed: ${Math.round((totalLines * numTimes) / timeSeconds)} lines per second`);
  }
}
开发者ID:alangpierce,项目名称:sucrase,代码行数:41,代码来源:benchmark-project.ts

示例4: yargs

export const parseArgs = (args: string): any => yargs(args);
开发者ID:Shane7,项目名称:Camelot-Unchained,代码行数:1,代码来源:slashCommands.ts

示例5:

import parse, { Arguments } from 'yargs-parser';

parse('--foo -bar');

parse(['--foo', '-bar']);

// prettier-ignore
// $ExpectError
parse(['--foo', '-bar'], {
    string: 123,
});

parse(['--foo', '-bar'], {
    // $ExpectError
    unknown: ['b', 'a', 'r'],
});

// alias

parse(['--foo', '-bar'], {
    alias: { foo: 'foo', bar: ['bar'] }
});

// array

parse(['--foo', '-bar'], {
    array: ['foo', 'bar']
});

parse(['--foo', '-bar'], {
    array: [{ key: 'foo', boolean: true }, { key: 'bar', number: true }],
开发者ID:TeamworkGuy2,项目名称:DefinitelyTyped,代码行数:31,代码来源:yargs-parser-tests.ts

示例6:

import parse, { Arguments } from 'yargs-parser';

parse('--foo -bar');

parse(['--foo', '-bar']);

parse(['--foo', '-bar'], {
    boolean: ['b', 'a', 'r'],
});

// prettier-ignore
// $ExpectError
parse(['--foo', '-bar'], {
    string: 123,
});

parse(['--foo', '-bar'], {
    // $ExpectError
    unknown: ['b', 'a', 'r'],
});

parse(['--foo', '-bar'], {
    alias: { foo: 'foo', bar: ['bar'] },
    '--': true,
});

parse(['--foo', '-bar'], {
    configuration: {
        'dot-notation': false,
    },
});
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:yargs-parser-tests.ts


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