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

TypeScript minimist类代码示例

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

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



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

示例1: loadSettingsFromArgs

/**
 * Parses the command-line arguments, extracting the tsickle settings and
 * the arguments to pass on to tsc.
 */
function loadSettingsFromArgs(args: string[]): {settings: Settings, tscArgs: string[]} {
  const settings: Settings = {};
  const parsedArgs = minimist(args);
  for (const flag of Object.keys(parsedArgs)) {
    switch (flag) {
      case 'h':
      case 'help':
        usage();
        process.exit(0);
        break;
      case 'externs':
        settings.externsPath = parsedArgs[flag];
        break;
      case 'typed':
        settings.isTyped = true;
        break;
      case 'verbose':
        settings.verbose = true;
        break;
      case '_':
        // This is part of the minimist API, and holds args after the '--'.
        break;
      default:
        console.error(`unknown flag '--${flag}'`);
        usage();
        process.exit(1);
    }
  }
  // Arguments after the '--' arg are arguments to tsc.
  const tscArgs = parsedArgs['_'];
  return {settings, tscArgs};
}
开发者ID:anbu004,项目名称:vinoth,代码行数:36,代码来源:main.ts


示例2: cmd

export default function cmd(args) {
  let argv = minimist(args);
  
  startServer({
    directory: argv['dir']  || config.directory,
    port:      argv['port'] || config.port
  });
}
开发者ID:JannesMeyer,项目名称:lumos,代码行数:8,代码来源:cmd-serve.ts


示例3: getArgumentsObject

 getArgumentsObject(args: string[]): Arguments{
   let obj : any = minimist(this.removeNodeAndFilename(args));
   let sortBy = "main.temp";
   if('sortBy' in obj){
     sortBy = obj.sortBy
   }
   return new Arguments(obj._, sortBy)
 }
开发者ID:AndersCan,项目名称:weather-api,代码行数:8,代码来源:Validator.ts


示例4: loadArgs

export function loadArgs(args: string[], defaults = DEFAULTS) {
  let config = R.clone(defaults);

  let argv = minimist(args, OPTIONS);
  if (argv['config']) {
    let file = argv['config'];
    if (typeof file === 'string') config = loadFile(file, config);
  }

  let object: any = {};

  object.client = {};
  if (argv['client']) object.client.name = argv['client'];
  if (argv['client-config']) {
    let clientConfig = argv['client-config'];
    if (typeof clientConfig === 'string') {
      object.client.config = JSON.parse(clientConfig);
    }
  }
  if (argv['journal-table']) object.client.journalTable = argv['journal-table'];

  if (argv['directory']) object.files = {directory: argv['directory']};

  if (argv['status']) object.command = 'status';
  if (argv['migrations']) object.command = 'migrations';
  if (argv['journal']) object.command = 'journal';
  if (argv['create']) object.command = 'create';
  if (argv['apply']) object.command = 'apply';
  if (argv['revert']) object.command = 'revert';
  if (argv['help']) object.command = 'help';
  if (argv['version']) object.command = 'version';
  let command: any = {};
  object.commands = {[object.command]: command};

  if (argv['id']) command.id = argv['id'];

  if (argv['long']) command.long = true;

  if (argv['combined']) command.split = false;
  if (argv['split']) command.split = true;

  command.templatePaths = {};
  if (argv['template']) command.templatePaths.combined = argv['template'];
  if (argv['up-template']) command.templatePaths.up = argv['up-template'];
  if (argv['down-template']) command.templatePaths.down = argv['down-template'];

  if (argv['all']) command.method = 'all';
  if (argv['each']) command.method = 'each';
  if (argv['dry']) command.method = 'dry';

  if (argv['pending']) command.pending = true;
  if (argv['to']) command.to = argv['to'];
  if (argv['number']) command.number = argv['number'];

  if (argv['_'].length) command.name = argv['_'].join('-');

  return loadObject(object, config);
}
开发者ID:programble,项目名称:careen,代码行数:58,代码来源:args.ts


示例5: minimist

        return Promise.resolve().then(() => {
            let args = minimist(environment.args);

            let RegisteredCommand = findCommand(environment.commands, args._[0]);

            let command = new RegisteredCommand({
                ui: this.ui,
                project: this.project
            });

            return command.validateAndRun(environment.args);
        }).catch(this.error.bind(this));
开发者ID:DevanB,项目名称:platypi-cli,代码行数:12,代码来源:cli.ts


示例6: main

function main(): void {
	const opts = minimist<PublishOptions>(process.argv.slice(2), {
		boolean: ['upload-only']
	});

	const [quality, platform, type, name, version, _isUpdate, file] = opts._;
	const commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();

	publish(commit, quality, platform, type, name, version, _isUpdate, file, opts).catch(err => {
		console.error(err);
		process.exit(1);
	});
}
开发者ID:FabianLauer,项目名称:vscode,代码行数:13,代码来源:publish.ts


示例7: main

async function main() {
  // Parse the command-line options.
  let args = minimist(process.argv.slice(2), {
    boolean: ['v', 'c', 'x', 'w', 't', 'g', 'P'],
  });

  // The flags: -v, -c, and -x.
  let verbose: boolean = args['v'];
  let compile: boolean = args['c'];
  let execute: boolean = args['x'];
  let webgl: boolean = args['w'];
  let test: boolean = args['t'];
  let generate: boolean = args['g'];
  let no_presplice: boolean = args['P'];
  let module: boolean = args['m'];

  // Help.
  if (args['h'] || args['help'] || args['?']) {
    console.error("usage: " + process.argv[1] + " [-vcxwtgP] [PROGRAM...]");
    console.error("  -v: verbose mode");
    console.error("  -c: compile (as opposed to interpreting)");
    console.error("  -x: execute the program (use with -c)");
    console.error("  -w: use the WebGL language variant");
    console.error("  -t: test mode (check for expected output)");
    console.error("  -g: dump generated code");
    console.error("  -P: do not use the presplicing optimization");
    console.error("  -m: compile an importable ES6 module");
    process.exit(1);
  }

  // Get the program filenames, or indicate that we'll read code from STDIN.
  let filenames: string[] = args._;
  if (!filenames.length) {
    filenames = [STDIN_FILENAME];
  }

  // Log stuff, if in verbose mode.
  let log = verbose ? verbose_log : (() => void 0);

  // Read each source file and run the driver.
  let success = true;
  await Promise.all(filenames.map(async fn => {
    let source = await readText(fn);
    success = run(fn, source, webgl, compile, execute, test,
        generate, log, !no_presplice, module) && success;
  }));
  if (!success) {
    process.exit(1);
  }
}
开发者ID:sampsyo,项目名称:braid,代码行数:50,代码来源:braid.ts


示例8: main

async function main(args: string[]): Promise<number> {
  /** Parse the command line. */
  const argv = minimist(args, { boolean: ['help'] });

  /** Create the DevKit Logger used through the CLI. */
  const logger = createConsoleLogger(argv['verbose']);

  // Check the target.
  const targetStr = argv._[0] || '';
  if (!targetStr || argv.help) {
    // Show architect usage if there's no target.
    usage(logger);
  }

  // Load workspace configuration file.
  const currentPath = process.cwd();
  const configFileNames = [
    'angular.json',
    '.angular.json',
    'workspace.json',
    '.workspace.json',
  ];

  const configFilePath = findUp(configFileNames, currentPath);

  if (!configFilePath) {
    logger.fatal(`Workspace configuration file (${configFileNames.join(', ')}) cannot be found in `
      + `'${currentPath}' or in parent directories.`);

    return 3;
  }

  const root = path.dirname(configFilePath);
  const configContent = readFileSync(configFilePath, 'utf-8');
  const workspaceJson = JSON.parse(configContent);

  const registry = new schema.CoreSchemaRegistry();
  registry.addPostTransform(schema.transforms.addUndefinedDefaults);

  const host = new NodeJsSyncHost();
  const workspace = new experimental.workspace.Workspace(normalize(root), host);

  await workspace.loadWorkspaceFromJson(workspaceJson).toPromise();

  // Clear the console.
  process.stdout.write('\u001Bc');

  return await _executeTarget(logger, workspace, root, argv, registry);
}
开发者ID:angular,项目名称:angular-cli,代码行数:49,代码来源:architect.ts


示例9: parseArgs

function parseArgs(args: string[] | undefined): minimist.ParsedArgs {
    return minimist(args, {
      boolean: booleanArgs,
      alias: {
        'dryRun': 'dry-run',
        'listSchematics': 'list-schematics',
        'allowPrivate': 'allow-private',
      },
      default: {
        'debug': null,
        'dry-run': null,
      },
      '--': true,
    });
}
开发者ID:cexbrayat,项目名称:angular-cli,代码行数:15,代码来源:schematics.ts


示例10: parseArguments

/**
 * Reads package prefix and all package names passed as command line arguments.
 * List of supported arguments:
 * --prefix    - prefix of the package. Also used as prefix in class names, selector prefixes etc.
 * --auth      - replacement for @nebular/auth
 * --bootstrap - replacement for @nebular/bootstrap
 * --date-fns  - replacement for @nebular/date-fns
 * --eva-icons - replacement for @nebular/eva-icons
 * --moment    - replacement for @nebular/moment
 * --theme     - replacement for @nebular/theme
 * --security  - replacement for @nebular/security
 * @param argv command line arguments
 * @returns ParsedArguments
 */
function parseArguments(argv: string[]): ParsedArguments {
  const args = minimist(argv.slice(2));
  const prefix = args.prefix;

  if (!prefix) {
    throwNoPrefixSpecified();
  }

  const parsedArguments = { prefix };
  for (const packageName of NEBULAR_PACKAGES) {
    parsedArguments[packageName] = args[dasherize(packageName)];
  }

  return parsedArguments;
}
开发者ID:kevinheader,项目名称:nebular,代码行数:29,代码来源:change-prefix.ts


示例11: handleCommand

  handleCommand(event: any, command: string, payload: Array<string>): void {
    console.log(this.commandList)
    if (!this.commandList[command]) return console.error('InvalidCommand:', command, ':', JSON.stringify(payload))

    let message = payload.join(' ').trim()
    let optionStartIndex = message.indexOf(' -')
    let parameter = message
    let options = {}

    if (!!~optionStartIndex) {
      parameter = message.substring(0, optionStartIndex).trim()
      options = minimist(message.substring(optionStartIndex).split(' '))
    }

    this.commandList[command].onCommand(event, parameter, options)
  }
开发者ID:jamesblack,项目名称:tsbot-discord,代码行数:16,代码来源:command-dispatcher.ts


示例12: getOption

  function getOption(name: string): string {
    if (configData) {
      return configData[name] || Private.getBodyData(name);
    }
    configData = Object.create(null);
    let found = false;

    // Use script tag if available.
    if (typeof document !== 'undefined') {
      const el = document.getElementById('jupyter-config-data');

      if (el) {
        configData = JSON.parse(el.textContent || '') as {
          [key: string]: string
        };
        found = true;
      }
    }
    // Otherwise use CLI if given.
    if (!found && typeof process !== 'undefined') {
      try {
        const cli = minimist(process.argv.slice(2));
        if ('jupyter-config-data' in cli) {
          const path: any = require('path');
          const fullPath = path.resolve(cli['jupyter-config-data']);

          /* tslint:disable */
          // Force Webpack to ignore this require.
          configData = eval('require')(fullPath) as { [key: string]: string };
          /* tslint:enable */
        }
      } catch (e) {
        console.error(e);
      }
    }

    if (!JSONExt.isObject(configData)) {
      configData = Object.create(null);
    } else {
      for (let key in configData) {
        // Quote characters are escaped, unescape them.
        configData[key] = String(configData[key]).split('&#39;').join('"');
      }
    }
    return configData![name] || '';
  }
开发者ID:7125messi,项目名称:jupyterlab,代码行数:46,代码来源:pageconfig.ts


示例13: getConfigOption

function getConfigOption(name: string): string {
  if (configData) {
    return configData[name];
  }
  if (typeof document === 'undefined') {
    configData = minimist(process.argv.slice(2));
  } else {
    let el = document.getElementById('jupyter-config-data');
    if (el) {
      configData = JSON.parse(el.textContent);
    } else {
      configData = {};
    }
  }
  configData = deepFreeze(configData);
  return configData[name];
}
开发者ID:afshin,项目名称:jupyter-js-services,代码行数:17,代码来源:utils.ts


示例14: main

function main(): void {
	if (process.env['VSCODE_BUILD_SKIP_PUBLISH']) {
		console.warn('Skipping publish due to VSCODE_BUILD_SKIP_PUBLISH');
		return;
	}

	const opts = minimist<PublishOptions>(process.argv.slice(2), {
		boolean: ['upload-only']
	});

	const [quality, platform, type, name, version, _isUpdate, file] = opts._;
	const commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();

	publish(commit, quality, platform, type, name, version, _isUpdate, file, opts).catch(err => {
		console.error(err);
		process.exit(1);
	});
}
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:18,代码来源:publish.ts


示例15: getOption

  function getOption(name: string): string {
    if (configData) {
      return configData[name] || '';
    }
    configData = Object.create(null);
    let found = false;

    // Use script tag if available.
    if (typeof document !== 'undefined') {
      let el = document.getElementById('jupyter-config-data');
      if (el) {
        configData = JSON.parse(el.textContent || '') as { [key: string]: string };
        console.log('\n\n\n******ho');
        found = true;
      }
    }
    // Otherwise use CLI if given.
    if (!found && typeof process !== 'undefined') {
      try {
        let cli = minimist(process.argv.slice(2));
        if ('jupyter-config-data' in cli) {
          let path: any = require('path');
          let fullPath = path.resolve(cli['jupyter-config-data']);
          // Force Webpack to ignore this require.
          configData = eval('require')(fullPath) as { [key: string]: string };
        }
      } catch (e) {
        console.error(e);
      }
    }

    if (!JSONExt.isObject(configData)) {
      configData = Object.create(null);
    } else {
      for (let key in configData) {
        configData[key] = String(configData[key]);
      }
    }
    console.log('\n\n\n******');
    console.log(JSON.stringify(configData, null, 2));
    return configData[name] || '';
  }
开发者ID:eskirk,项目名称:jupyterlab,代码行数:42,代码来源:pageconfig.ts


示例16: main

export function main() {
  let options = minimist(process.argv.slice(2), MINIMIST_OPTIONS);
  if (options.help || options._.length < 1 || options._.length > 2) {
    console.log(USAGE);
    return die();
  }

  const inFilename = options._[0];
  const outFilename = options._[1];

  try {
    let codemap: string[][] | undefined;

    const font = loadFont(options, inFilename);
    verbose(options, `Loaded font ${inFilename}: ${font.glyphs.length} glyphs, ` +
      (font.isMonospace ? "monospace" : "proportional") + `, ${font.maxCellWidth()} x ${font.cellHeight}`);

    if (options.scale) font.scale(parseInt(options.scale, 10));

    if (outFilename) {
      if (options.sample) {
        const fb = writeSample(options, font, options.sample);
        fs.writeFileSync(outFilename, writeBmp(fb));
        verbose(options, `Wrote sample text (${fb.width} x ${fb.height}) to file: ${outFilename}`);
      } else {
        saveFont(options, font, outFilename);
        if (options["write-map"]) {
          const mapFilename = outFilename.replace(/\.\w+$/, ".psfmap");
          fs.writeFileSync(mapFilename, dumpCodemap(font.codemap));
          verbose(options, `Wrote codemap file: ${mapFilename}`);
        }
      }
    }
    if (options.ascii) {
      const rowsize = parseInt(options.termwidth, 10);
      exportAscii(font, rowsize).forEach(line => process.stdout.write(line + "\n"));
    }
  } catch (error) {
    die(error);
  }
}
开发者ID:robey,项目名称:font-problems,代码行数:41,代码来源:font_problems.ts


示例17: getSemanticVersion

export function getSemanticVersion() {
    const options = minimist(process.argv.slice(2), {});
    let version = options.version;
    if (!version) {
        version = "0.0.0";
        console.log("No version argument provided, fallback to default version: " + version);
    } else {
        console.log("Found version: " + version);
    }

    if (!semver.valid(version)) {
        throw new Error("Package: invalid semver version: " + version);
    }

    let patch = semver.patch(version);

    if (!options.noversiontransform) {
        patch *= 1000;
        const prerelease = semver.prerelease(version);
        if (prerelease) {
            patch += parseInt(prerelease[1], 10);
        } else {
            patch += 999;
        }
    }

    const result = {
        major: semver.major(version),
        minor: semver.minor(version),
        patch,
        getVersionString() {
            return this.major.toString() + "." + this.minor.toString() + "." + this.patch.toString();
        },
    };

    console.log("Extension Version: " + result.getVersionString());

    return result;
}
开发者ID:geeklearningio,项目名称:gl-vsts-tasks-build-scripts,代码行数:39,代码来源:extension-version.ts


示例18: cmd

// Needs an absolute path
export default function cmd(args) {
  var argv = minimist(args);
  if (argv._.length === 0) {
    throw new Error('Need more arguments');
  }

  if (argv['decode-uri-component']) {
    // escape() will not encode: @*/+
    // (encodes Unicode characters to Unicode escape sequences, too)
    // encodeURI() will not encode: ~!@#$&*()=:/,;?+'
    // encodeURIComponent() will not encode: ~!*()'
    argv._ = argv._.map((file, i) => {
      return decodeURIComponent(file);
    });
  }
  // Open the files in an editor
  createFiles(argv._)
  .then(() => {
    // TODO: respect errors
    editor(argv._);
  });
}
开发者ID:JannesMeyer,项目名称:lumos,代码行数:23,代码来源:cmd-edit.ts


示例19: cmd

export default function cmd(args) {
  var argv = minimist(args);

  if (argv._.length === 0) {
    throw new Error('Not enough arguments');
  }

  var pathname;
  // convert to pathname
  if (argv['base-path']) {
    var basePath = argv['base-path'];
    var absPath = argv._[0];

    if (absPath.startsWith(basePath)) {
      var baseStripped = absPath.substring(basePath.length);
      pathname = (baseStripped.startsWith('/') ? '' : '/') + baseStripped;
    } else {
      throw new Error('The provided path does not start with <base-path>');
    }
  } else {
    pathname = '/' + argv._[0];
  }

  // Strip "(index).md" from the end
  if (pathname.endsWith(config.indexFile)) {
    pathname = pathname.slice(0, -config.indexFile.length);
  } else if (pathname.endsWith(config.mdSuffix)) {
    pathname = pathname.slice(0, -config.mdSuffix.length);
  }

  // Open URL in browser
  var baseUrl = 'http://notes';
  var url = baseUrl + pathname;
  console.log('Opening...', url);
  // TODO: make this cross-platform, but without exec()
  // https://www.npmjs.org/package/open
  spawn('open', [url], { stdio: 'inherit' });
}
开发者ID:JannesMeyer,项目名称:lumos,代码行数:38,代码来源:cmd-view.ts


示例20: return

    return (done: (err?: Error) => any) => {
        if (fs.existsSync(path.join(project.directory, "node_modules"))) {

            const modcleanOptions: any = {
                cwd: project.directory,
            };

            const options = minimist(process.argv.slice(2), {});

            if (options.patterns) {
                modcleanOptions.patterns = options.patterns.split(",");
            }

            if (options.additionalpatterns) {
                modcleanOptions.additionalPatterns = options.additionalpatterns.split(",");
            }

            if (options.ignorepatterns) {
                modcleanOptions.ignorePatterns = options.ignorepatterns.split(",");
            }

            modclean(modcleanOptions, (err: Error, results: string[]) => {
                // called once cleaning is complete.
                if (err) {
                    console.error(`exec error: ${err}`);
                    done(err);
                    return;
                }

                console.log(`${results.length} files removed!`);
                done();
            });

        } else {
            console.log(`modclean skipped for ${project.name}`);
            done();
        }
    };
开发者ID:geeklearningio,项目名称:gl-vsts-tasks-build-scripts,代码行数:38,代码来源:node-modclean.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript mithril类代码示例发布时间:2022-05-28
下一篇:
TypeScript minimatch类代码示例发布时间: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