当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript minimist类代码示例

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


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


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