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

TypeScript command-line-args类代码示例

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

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



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

示例1: readCommandLineOptions

/** Reads options from command line, requires command-line-args */
function readCommandLineOptions() {
    function resolveKeyValuePairs(kvs: string[]) {
        var o: any = {};
        for (var i=0; i<kvs.length; i++) {
            var kv = kvs[i].split("=");
            o[kv[0]] = kv[1] || true;
        }
        return o;
    }
    var opts = commandLineArgs(optionDefinitions);
    // Latest version of command-line-args doesn't set empty flags to true but null
    for (var k in opts) {
        if (opts[k] === null)
            opts[k] = true;
    }
    if (opts.help) {
        fableLib.stdoutLog(commandLineUsage(getAppDescription()));
        fableLib.finish(0);
    }
    if (opts.refs) {
        opts.refs = resolveKeyValuePairs(opts.refs);
    }
    if (opts.coreLib) {
        opts.refs = Object.assign(opts.refs || {}, { "Fable.Core": opts.coreLib })
        delete opts.coreLib;
    }
    if (opts.extra) {
        opts.extra = resolveKeyValuePairs(opts.extra);
    }
    return opts;
}
开发者ID:7sharp9,项目名称:Fable,代码行数:32,代码来源:options.ts


示例2: run

'use strict';
import {polylint} from './polylint';
import * as jsconf_policy from './jsconf-policy';
import * as cliArgs from "command-line-args";
import * as fs from 'fs';
import * as path from 'path';
import * as logging from 'plylog'
import pathIsAbsolute = require('path-is-absolute');

//Trying to import this the TS leads to some really strange errors
var colors = require('colors/safe');

var argumentDefinitions = require('./args').argumentDefinitions;
var logger = logging.getLogger('lint.cli');

const cli = cliArgs(argumentDefinitions);

var usage = cli.getUsage({
  header: "polylint checks Polymer apps for problematic code patterns",
  title: "polylint"
});

export function run(env, args, stdout) {
  return new Promise(function(resolve, reject) {
    var cliOptions;
    try {
      cliOptions = cli.parse();
    } catch (e) {
      console.log(usage);
      resolve();
      return;
开发者ID:PolymerLabs,项目名称:polylint,代码行数:31,代码来源:cli.ts


示例3: startServer

  return new Promise<void>((resolve, reject) => {
    let argsWithHelp : ArgDescriptor[] = args.concat({
      name: 'help',
      description: 'Shows this help message',
      type: Boolean,
    });
    var cli = commandLineArgs(argsWithHelp);

    try {
      var cliOptions = cli.parse();
    }
    catch (e) {
      printUsage(cli);
      reject();
      return;
    }

    var options: ServerOptions = {
      port: cliOptions.port,
      hostname: cliOptions.hostname,
      open: cliOptions.open,
      browser: cliOptions.browser,
      componentDir: cliOptions['component-dir'],
      packageName: cliOptions['package-name'],
    }

    if (cliOptions.help) {
      printUsage(cli);
      reject();
      resolve();
    } else {
      return startServer(options);
    }
  });
开发者ID:danners,项目名称:polyserve,代码行数:34,代码来源:cli.ts


示例4: commandLineArgs

(async () => {
  const options = commandLineArgs(cliDefs) as CliOpts;
  const skipSourceUpdate = options['skip-source-update'];

  let exitCode = 0;

  await Promise.all([
    updateFixture({
      folder: 'polymer',
      branch: '2.x',
      repoUrl: 'https://github.com/Polymer/polymer.git',
      skipSourceUpdate,
    }),
    updateFixture({
      folder: 'paper-button',
      branch: '2.x',
      repoUrl: 'https://github.com/PolymerElements/paper-button.git',
      skipSourceUpdate,
    }),
    updateFixture({
      folder: 'iron-icon',
      branch: '2.x',
      repoUrl: 'https://github.com/PolymerElements/iron-icon.git',
      skipSourceUpdate,
    }),
  ].map((p) => p.catch((e) => {
    // Exit with an error code if any fixture fails, but let them all finish.
    console.error(e);
    exitCode = 1;
  })));

  process.exit(exitCode);
})();
开发者ID:,项目名称:,代码行数:33,代码来源:


示例5: runWorkspaceCommand

export async function run() {
  const options = commandLineArgs(optionDefinitions) as CliOptions;

  if (options['help']) {
    const getUsage = require('command-line-usage');
    const usage = getUsage([
      {
        header: 'modulizer',
        content: `Convert HTML Imports to JavaScript modules

If no GitHub repository names are given, modulizer converts the current
directory as a package. If repositories are provided, they are cloned into a
workspace directory as sibling folders as they would be in a Bower
installation.
`,
      },
      {
        header: 'Options',
        optionList: optionDefinitions,
      }
    ]);
    console.log(usage);
    return;
  }

  if (options['version']) {
    console.log(require('../../package.json').version);
    return;
  }

  if (options['repo']) {
    await runWorkspaceCommand(options);
    return;
  }

  const importStyle = options['import-style'];
  if (importStyle !== 'name' && importStyle !== 'path') {
    throw new Error(
        `import-style "${importStyle}" not supported. ` +
        `Supported styles: "name", "path".`);
  }

  const packageType = options['package-type'];
  if (packageType !== 'element' && packageType !== 'application') {
    throw new Error(
        `package-type "${packageType}" is not supported. ` +
        `Supported types: "element", "application".`);
  }

  await runPackageCommand(options);
}
开发者ID:,项目名称:,代码行数:51,代码来源:


示例6: main

const optionDescriptors = [
  {name: 'help', type: Boolean}, {name: 'version', type: Boolean},
  {name: 'logToFile', type: String},
  // these args are passed in by vscode by default, even though
  // we don't care about them right now we don't want to fail
  // if they're given.
  {name: 'stdio'}, {name: 'clientProcessId', type: Number}
];

interface Options {
  help?: boolean;
  version?: boolean;
  logToFile?: string;
}

const options = commandLineArgs(optionDescriptors, {}) as Options;

/**
 * Implements the [language server protocol][1] v3.0 for Web Components and
 * Polymer.
 *
 * Communicates over stdin/stdout.
 *
 * [1]: https://github.com/Microsoft/language-server-protocol
 */
async function main(options: Options) {
  // This import *must* come before all others.
  await import('./intercept-logs');
  //

  const {createConnection} = await import('vscode-languageserver');
开发者ID:MehdiRaash,项目名称:tools,代码行数:31,代码来源:polymer-language-server.ts


示例7: parseInt

const cli = cliArgs([
  {name: 'help', type: Boolean, alias: 'h', description: 'Print usage.'},
  {
    name: 'maxChanges',
    type: (x: string) => {
      if (!x) {
        return 0;
      }
      if (/^[0-9]+$/.test(x)) {
        return parseInt(x, 10);
      }
      throw new Error(`invalid max changes, expected an integer: ${x}`);
    },
    alias: 'c',
    description: 'The maximum number of repos to push. Default: 0',
    defaultValue: 0
  },
  {
    name: 'repo',
    type: (s) => {
      if (!s) {
        throw new Error('Value expected for --repo|-r flag');
      }
      const parts = s.split('/');
      if (parts.length !== 2) {
        throw new Error(`Given repo ${s} is not in form user/repo`);
      }
      return {user: parts[0], repo: parts[1]};
    },
    defaultValue: [],
    multiple: true,
    alias: 'r',
    description:
        'Explicit repos to process. Specifying explicit repos will disable running on the implicit set of repos for the user.'
  },
  {
    name: 'pass',
    multiple: true,
    type: (passName) => {
      if (passNames.indexOf(passName) < 0) {
        throw new Error(`Unknown cleanup pass name "${passName}"`);
      }
      return passName;
    },
    defaultValue: [],
    description:
        `Cleanup passes to run. If this flag is used then only the given passes will run, and they will run even if they're disabled by default. Pass names: ${
            passNames.join(', ')}`
  },
  {
    name: 'branchToFix',
    alias: 'b',
    description:
        `The branch to apply changes to. Repos without a branch of this name will be skipped.`,
    type: String,
    defaultValue: 'master'
  },
  {
    name: 'noProgress',
    description: `If true, does not display a progress bar while it works.`,
    type: Boolean,
    defaultValue: false
  },
  {
    name: 'forceReview',
    description:
        `If true, all changes will go through review, even if tedium thinks they're safe and boring.`,
    type: Boolean,
    defaultValue: false
  },
  {
    name: 'prBranchName',
    description:
        'When sending up a PR, push to this branch and then make a PR from it.',
    type: String,
    defaultValue: 'tedium-change'
  },
  {
    name: 'prAssignee',
    description:
        'When sending up a PR, assign it to this person to review. If not given, the asignee will be inferred from the github token (i.e. it will be assigned to YOU!)',
    type: String,
    defaultValue: undefined,
  }
]);
开发者ID:TimvdLippe,项目名称:tedium,代码行数:85,代码来源:tedium.ts


示例8: printHelp

            'polymer-bundler --exclude "path/to/target/subpath/" --exclude "path/to/target/subpath2/" target.html'
      },
      {
        desc:
            'Inline scripts in \`target.html\` as well as HTML Imports. Exclude flags will apply to both Imports and Scripts.',
        example: 'polymer-bundler --inline-scripts target.html'
      },
      {
        desc: 'Route URLs starting with "myapp://" to folder "src/myapp".',
        example: 'polymer-bundler --redirect="myapp://|src/myapp" target.html'
      }
    ]
  },
];

const options = commandLineArgs(optionDefinitions);
const projectRoot = resolvePath(ensureTrailingSlash(options.root || '.'));

const entrypoints: PackageRelativeUrl[] = options['in-file'];

function printHelp() {
  console.log(commandLineUsage(usage));
}

const pkg = require('../../package.json');
function printVersion() {
  console.log('polymer-bundler:', pkg.version);
}

if (options.version) {
  printVersion();
开发者ID:Polymer,项目名称:vulcanize,代码行数:31,代码来源:polymer-bundler.ts


示例9: args

        alias: "h",
        description: "Display this usage guide.",
        name: "help",
        type: Boolean,
    },
    {
        alias: "c",
        defaultValue: "config.yaml",
        description: "The AS config file.",
        name: "config",
        type: String,
        typeLabel: "<config.yaml>",
    },
];

const options = args(optionDefinitions);

if (options.help) {
    /* tslint:disable:no-console */
    console.log(usage([
    {
        content: "A tool to fix channels of rooms already bridged " +
        "to matrix, to make sure their names, icons etc. are correctly.",
        header: "Fix bridged channels",
    },
    {
        header: "Options",
        optionList: optionDefinitions,
    },
    ]));
    process.exit(0);
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:31,代码来源:chanfix.ts


示例10: parseInt

const cli = cliArgs([
  {name: "help", type: Boolean, alias: "h", description: "Print usage."},
  {
    name: "max_changes",
    type: (x: string) => {
      if (!x) {
        return 0;
      }
      if (/^[0-9]+$/.test(x)) {
        return parseInt(x, 10);
      }
      throw new Error(`invalid max changes, expected an integer: ${x}`);
    },
    alias: "c",
    description: "The maximum number of repos to push. Default: 0",
    defaultValue: 0
  },
  {
    name: 'repo',
    type: (s) => {
      if (!s) {
        throw new Error('Value expected for --repo|-r flag');
      }
      let parts = s.split('/');
      if (parts.length !== 2) {
        throw new Error(`Given repo ${s} is not in form user/repo`);
      }
      return {user: parts[0], repo: parts[1]};
    },
    defaultValue: [],
    multiple: true,
    alias: 'r',
    description:
        'Explicit repos to process. Specifying explicit repos will disable running on the implicit set of repos for the user.'
  },
  {
    name: 'pass',
    multiple: true,
    type: (passName) => {
      if (passNames.indexOf(passName) < 0) {
        throw new Error(`Unknown cleanup pass name "${passName}"`);
      }
      return passName;
    },
    defaultValue: [],
    description: `Cleanup passes to run. If this flag is used then only the given passes will run, and they will run even if they're disabled by default. Pass names: ${passNames.join(', ')}`
  }
]);
开发者ID:BruceZu,项目名称:tedium,代码行数:48,代码来源:tedium.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript command-line-usage类代码示例发布时间:2022-05-28
下一篇:
TypeScript color类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap