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

TypeScript yargs.default函数代码示例

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

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



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

示例1: default_hash

function default_hash() {
    let argv = yargs
        .default({ x: 10, y: 10 })
        .argv
        ;
    console.log(argv.x + argv.y);
}
开发者ID:markusmauch,项目名称:DefinitelyTyped,代码行数:7,代码来源:yargs-tests.ts


示例2: randomValue

function Argv$default() {
    let ya = yargs
        .default('random', function randomValue() {
            return Math.random() * 256;
        })
        .argv;
}
开发者ID:markusmauch,项目名称:DefinitelyTyped,代码行数:7,代码来源:yargs-tests.ts


示例3: default_singles

// EVEN MORE SHIVER ME TIMBERS!
function default_singles() {
    let argv = yargs
        .default('x', 10)
        .default('y', 10)
        .argv
        ;
    console.log(argv.x + argv.y);
}
开发者ID:markusmauch,项目名称:DefinitelyTyped,代码行数:9,代码来源:yargs-tests.ts


示例4: getFlags

export function getFlags(manualArgv?: string) {
  const y = manualArgv ? yargs(manualArgv) : yargs;

  return y.help('help')
      .version(() => pkg.version)
      .showHelpOnFail(false, 'Specify --help for available options')

      .usage('lighthouse <url>')
      .example(
          'lighthouse <url> --view', 'Opens the HTML report in a browser after the run completes')
      .example(
          'lighthouse <url> --config-path=./myconfig.js',
          'Runs Lighthouse with your own configuration: custom audits, report generation, etc.')
      .example(
          'lighthouse <url> --output=json --output-path=./report.json --save-assets',
          'Save trace, screenshots, and named JSON report.')
      .example(
          'lighthouse <url> --disable-device-emulation --disable-network-throttling',
          'Disable device emulation')
      .example(
          'lighthouse <url> --chrome-flags="--window-size=412,732"',
          'Launch Chrome with a specific window size')
      .example(
          'lighthouse <url> --quiet --chrome-flags="--headless"',
          'Launch Headless Chrome, turn off logging')

      // List of options
      .group(['verbose', 'quiet'], 'Logging:')
      .describe({
        verbose: 'Displays verbose logging',
        quiet: 'Displays no progress, debug logs or errors'
      })

      .group(
          [
            'save-assets', 'save-artifacts', 'list-all-audits', 'list-trace-categories',
            'additional-trace-categories', 'config-path', 'chrome-flags', 'perf', 'port',
            'hostname', 'max-wait-for-load'
          ],
          'Configuration:')
      .describe({
        'blocked-url-patterns': 'Block any network requests to the specified URL patterns',
        'disable-storage-reset':
            'Disable clearing the browser cache and other storage APIs before a run',
        'disable-device-emulation': 'Disable Nexus 5X emulation',
        'disable-cpu-throttling': 'Disable CPU throttling',
        'disable-network-throttling': 'Disable network throttling',
        'save-assets': 'Save the trace contents & screenshots to disk',
        'save-artifacts': 'Save all gathered artifacts to disk',
        'list-all-audits': 'Prints a list of all available audits and exits',
        'list-trace-categories': 'Prints a list of all required trace categories and exits',
        'additional-trace-categories':
            'Additional categories to capture with the trace (comma-delimited).',
        'config-path': 'The path to the config JSON.',
        'chrome-flags':
            `Custom flags to pass to Chrome (space-delimited). For a full list of flags, see http://peter.sh/experiments/chromium-command-line-switches/.

            Environment variables:
            CHROME_PATH: Explicit path of intended Chrome binary. If set must point to an executable of a build of Chromium version 54.0 or later. By default, any detected Chrome Canary or Chrome (stable) will be launched.
            `,
        'perf': 'Use a performance-test-only configuration',
        'hostname': 'The hostname to use for the debugging protocol.',
        'port': 'The port to use for the debugging protocol. Use 0 for a random port',
        'max-wait-for-load':
            'The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue. WARNING: Very high values can lead to large traces and instability',
        'interactive': 'Open Lighthouse in interactive mode'
      })

      .group(['output', 'output-path', 'view'], 'Output:')
      .describe({
        'output': `Reporter for the results, supports multiple values`,
        'output-path': `The file path to output the results. Use 'stdout' to write to stdout.
If using JSON output, default is stdout.
If using HTML output, default is a file in the working directory with a name based on the test URL and date.
If using multiple outputs, --output-path is ignored.
Example: --output-path=./lighthouse-results.html`,
        'view': 'Open HTML report in your browser'
      })

      // boolean values
      .boolean([
        'disable-storage-reset', 'disable-device-emulation', 'disable-cpu-throttling',
        'disable-network-throttling', 'save-assets', 'save-artifacts', 'list-all-audits',
        'list-trace-categories', 'perf', 'view', 'verbose', 'quiet', 'help', 'interactive'
      ])
      .choices('output', GetValidOutputOptions())
      // force as an array
      .array('blocked-url-patterns')

      // default values
      .default('chrome-flags', '')
      .default('disable-cpu-throttling', false)
      .default('output', GetValidOutputOptions()[OutputMode.domhtml])
      .default('port', 0)
      .default('hostname', 'localhost')
      .default('max-wait-for-load', Driver.MAX_WAIT_FOR_FULLY_LOADED)
      .check((argv: {listAllAudits?: boolean, listTraceCategories?: boolean, _: Array<any>}) => {
        // Make sure lighthouse has been passed a url, or at least one of --list-all-audits
        // or --list-trace-categories. If not, stop the program and ask for a url
        if (!argv.listAllAudits && !argv.listTraceCategories && argv._.length === 0) {
//.........这里部分代码省略.........
开发者ID:curtisk,项目名称:lighthouse,代码行数:101,代码来源:cli-flags.ts


示例5: setUpCli

export default function setUpCli(args?: string[], log = logResult) {
  // can't call argv before done setting up
  const verbose = !!args.find(arg => arg === '-v' || arg === '--verbose');
  const plugins = getArgs(args, ['--plugins', '-p']);
  const types = getArgs(args, ['--types', '-t']);

  loadConfiguration(plugins, types, verbose);

  const yargsConfig = yargs(args)
    .scriptName('jimp')
    .wrap(yargs.terminalWidth())
    .option('plugins', {
      alias: 'p',
      type: 'array',
      describe: 'Jimp plugins to load.'
    })
    .option('types', {
      alias: 't',
      type: 'array',
      describe: 'Jimp types to load.'
    })
    .option('verbose', {
      alias: 'v',
      type: 'boolean',
      describe: 'enable more logging'
    })
    .option('loadFont', {
      alias: 'f',
      type: 'string',
      describe: 'Path of font to load and be used in text operations'
    })
    .group(['plugins', 'types', 'loadFont'], 'Jimp Configuration:')
    .example(
      '$0 read path/to/image.png --output output.jpg',
      'Convert images from one type to another. See more under jimp read --help'
    )
    .alias('font', 'loadFont')
    .demandCommand(1, 'You need at least one command before moving on')
    .command({
      command: 'read [img]',
      describe: 'Read and image into jimp. (PNG, JPEG, TIFF, BMP, or GIF)',
      builder: yargs =>
        yargs
          .group(['output', 'actions'], 'Jimp Configuration:')
          .option('output', {
            alias: 'o',
            describe: 'file to output from jimp. (PNG, JPEG, TIFF, or BMP)'
          })
          .option('actions', {
            alias: 'a',
            type: 'array',
            describe: `actions (image manipulation) to run on the input image. Loaded functions ${Object.keys(
              Jimp.prototype
            )
              .sort()
              .join(', ')}`
          })
          .example(
            '$0 read path/to/image.png -a greyscale -a  resize 150 -1 --output output.jpg',
            'Apply image manipulations functions'
          )
          .example(
            '$0 read path/to/image.png --loadFont FONT_SANS_8_WHITE -a yarnprint 0 0 "Some text" --output output.jpg',
            'Use fonts'
          )
          .example(
            '$0 read path/to/image.png --plugins @jimp/plugin-circle -a circle --output output.jpg',
            'Use plugins'
          )
          .example(
            '$0 read path/to/image.png -a blit /path/to/image.png 0 0 --output output.jpg',
            'Use blit composite or mask'
          )
    })
    .command({
      command: 'create',
      describe: 'Create a new image',
      builder: yargs =>
        yargs
          .group(['width', 'height', 'background'], 'New Image Configuration:')
          .group(['output', 'actions'], 'Jimp Configuration:')
          .demandOption(
            ['width', 'height'],
            'Please provide both height and width to create new image'
          )
          .option('width', {
            alias: 'w',
            type: 'number',
            describe: 'Width of new image'
          })
          .option('height', {
            alias: 'he',
            type: 'number',
            describe: 'Height of new image'
          })
          .option('background', {
            alias: 'b',
            describe: 'Background color - either hex value or css string'
          })
          .option('output', {
//.........这里部分代码省略.........
开发者ID:oliver-moran,项目名称:jimp,代码行数:101,代码来源:cli.ts


示例6: yargs

import yargs from "yargs";

import {
  create,
} from "./index";

const argv = yargs(process.argv.slice(2))

  .usage("Usage: $0 [options]")

  .example("webpack-browser-sync", "")

  .options({
    config: {
      description: "path to webpack.config",
      alias: "c",
      default: "./webpack.config.js",
      required: true,
    },
    webpack: {
      description: "enable webpack",
      type: "boolean",
      default: true,
    },
    index: {
      description: "index.html relative path from webpackConfig.output.path",
      type: "string",
      default: "index.html",
    },
    hot: {
      description: "enable hot module replacement [need enabled webpack]",
开发者ID:morlay,项目名称:webpack-browser-sync,代码行数:31,代码来源:command.ts


示例7: getVersion

export const buildArgv = (maybeArgv?: Array<string>): Config.Argv => {
  const version =
    getVersion() +
    (__dirname.includes(`packages${path.sep}jest-cli`) ? '-dev' : '');

  const rawArgv: Config.Argv | Array<string> =
    maybeArgv || process.argv.slice(2);
  const argv: Config.Argv = yargs(rawArgv)
    .usage(args.usage)
    .version(version)
    .alias('help', 'h')
    .options(args.options)
    .epilogue(args.docs)
    .check(args.check).argv;

  validateCLIOptions(
    argv,
    {...args.options, deprecationEntries},
    // strip leading dashes
    Array.isArray(rawArgv)
      ? rawArgv.map(rawArgv => rawArgv.replace(/^--?/, ''))
      : Object.keys(rawArgv),
  );

  // strip dashed args
  return Object.keys(argv).reduce(
    (result, key) => {
      if (!key.includes('-')) {
        result[key] = argv[key];
      }
      return result;
    },
    {} as Config.Argv,
  );
};
开发者ID:facebook,项目名称:jest,代码行数:35,代码来源:index.ts


示例8: parseChromeFlags

export function parseChromeFlags(flags: string) {
  let args = yargs(flags).argv;
  const allKeys = Object.keys(args);

  // Remove unneeded arguments (yargs includes a _ arg, $-prefixed args, and camelCase dupes)
  return allKeys.filter(k => k !== '_' && !k.startsWith('$') && !/[A-Z]/.test(k))
      .map(k => formatArg(k, args[k]));
}
开发者ID:hmeng7,项目名称:lighthouse,代码行数:8,代码来源:run.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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