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

TypeScript yargs.terminalWidth函数代码示例

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

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



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

示例1:

function Argv$wrap() {
    let argv1 = yargs
        .wrap(null);

    let argv2 = yargs
        .wrap(yargs.terminalWidth());
}
开发者ID:markusmauch,项目名称:DefinitelyTyped,代码行数:7,代码来源:yargs-tests.ts


示例2: 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


示例3: getFlags


//.........这里部分代码省略.........
      .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) {
          throw new Error('Please provide a url');
        }

        return true;
      })
      .epilogue(
          'For more information on Lighthouse, see https://developers.google.com/web/tools/lighthouse/.')
      .wrap(yargs.terminalWidth())
      .argv;
}
开发者ID:curtisk,项目名称:lighthouse,代码行数:101,代码来源:cli-flags.ts


示例4: run

export async function run() {
  const yargs = require("yargs");

  const argv = yargs
    .usage("lerna-changelog [options]")
    .options({
      from: {
        type: "string",
        desc: "A git tag or commit hash that determines the lower bound of the range of commits",
        defaultDescription: "latest tagged commit",
      },
      to: {
        type: "string",
        desc: "A git tag or commit hash that determines the upper bound of the range of commits",
      },
      "tag-from": {
        hidden: true,
        type: "string",
        desc: "A git tag that determines the lower bound of the range of commits (defaults to last available)",
      },
      "tag-to": {
        hidden: true,
        type: "string",
        desc: "A git tag that determines the upper bound of the range of commits",
      },
      "next-version": {
        type: "string",
        desc: "The name of the next version",
        default: "Unreleased",
      },
      "next-version-from-metadata": {
        type: "boolean",
        desc: "Infer the name of the next version from package metadata",
        default: false,
      },
    })
    .example(
      "lerna-changelog",
      'create a changelog for the changes after the latest available tag, under "Unreleased" section'
    )
    .example(
      "lerna-changelog --from=0.1.0 --to=0.3.0",
      "create a changelog for the changes in all tags within the given range"
    )
    .epilog("For more information, see https://github.com/lerna/lerna-changelog")
    .wrap(Math.min(100, yargs.terminalWidth()))
    .parse();

  let options = {
    tagFrom: argv["from"] || argv["tag-from"],
    tagTo: argv["to"] || argv["tag-to"],
  };

  try {
    let config = loadConfig({
      nextVersionFromMetadata: argv["next-version-from-metadata"],
    });

    if (argv["next-version"]) {
      config.nextVersion = argv["next-version"];
    }

    let result = await new Changelog(config).createMarkdown(options);

    let highlighted = highlight(result, {
      language: "Markdown",
      theme: {
        section: chalk.bold,
        string: chalk.hex("#0366d6"),
        link: chalk.dim,
      },
    });

    console.log(highlighted);
  } catch (e) {
    if (e instanceof ConfigurationError) {
      console.log(chalk.red(e.message));
    } else {
      console.log(chalk.red(e.stack));
    }
  }
}
开发者ID:lerna,项目名称:lerna-changelog,代码行数:82,代码来源:cli.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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