當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。