How to use the nopt.bind function in nopt

To help you get started, we’ve selected a few nopt 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 ember-cli / ember-cli / lib / cli-old.js View on Github external
var cmd = this.cmd;
  cmd = commandAliases[cmd] ? commandAliases[cmd] : cmd;
  var action = this.commands[cmd];

  this.insight.track('ember', cmd);

  if (cmd && !action) {
    this.ui.write('The specified command ' + chalk.underline(cmd) + ' is invalid, for available options see `ember help`\n\n');
    return;
  }

  if (!action) {
    action = this.commands.help;
  }

  var parseOpts = nopt.bind(null, action.types, action.shorthands);
  var opts = parseOpts(this.argv);

  if(defaults !== undefined) {
    defaults = nopt(action.types, action.shorthands, defaults, 0);
  } else {
    defaults = {};
  }

  var options = merge({}, opts, defaults, {
    appRoot: process.cwd(),
    cliRoot: path.resolve(path.join(__dirname, '..'))
  });

  var args = options.argv.remain.slice();

  args.shift(); // remove CMD

nopt

Option parsing for Node, supporting types, shorthands, etc. Used by npm.

ISC
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis