How to use minimist-options - 2 common examples

To help you get started, we’ve selected a few minimist-options examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zce / zce-cli / src / core / parser.ts View on Github external
export const parse = async (
  argv: string[],
  opts?: Options
): Promise => {
  opts = opts || {}
  // cli brand name
  const brand =
    typeof pkg.bin === 'string'
      ? basename(pkg.bin, '.js')
      : Object.keys(pkg.bin)[0]

  // parse argv by minimist
  const options = minimist(argv, buildOptions(opts))

  // row input args
  const input = options._

  // extract arguments
  const [primary, secondary, thirdly, fourthly, ...extras] = input

  // excluding aliases
  Object.values(opts).forEach(item => {
    if (typeof item !== 'string' && item.alias) {
      if (typeof item.alias === 'string') {
        delete options[item.alias]
      } else {
        item.alias.forEach(a => delete options[a])
      }
    }
github ModusCreateOrg / gimbal / packages / gimbal / src / utils / Cli.ts View on Github external
public get args(): ParsedArgs {
    if (this.argCache) {
      logger.verbose('Returning cli args from argCache');

      return this.argCache.args;
    }

    const cliArgs = process.argv.slice(2);
    const options = buildOptions(this.options);
    const args = minimist(cliArgs, options);
    const parsedArgs = this.parseArgs(args);

    logger.verbose('Building new cli args...');
    logger.verbose(`  Options: ${JSON.stringify(this.options)}`);
    logger.verbose(`  process.argv: ${JSON.stringify(cliArgs)}`);
    logger.verbose(`  args: ${JSON.stringify(args)}`);
    logger.verbose(`  parsed args: ${JSON.stringify(parsedArgs)}`);

    logger.verbose('Saving cli args to cache');

    this.argCache = {
      args,
      options: this.options,
    };

minimist-options

Pretty options for minimist

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis

Popular minimist-options functions