How to use the dashdash.bashCompletionFromOptions function in dashdash

To help you get started, we’ve selected a few dashdash 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 ORESoftware / npm-link-up / index.js View on Github external
process.exit(1);
}
if (opts.version) {
    var npmLinkUpPkg = require('./package.json');
    console.log(npmLinkUpPkg.version);
    process.exit(0);
}
if (opts.help) {
    var help = parser.help({ includeEnv: true }).trimRight();
    console.log('usage: node foo.js [OPTIONS]\n'
        + 'options:\n'
        + help);
    process.exit(0);
}
if (opts.completion) {
    var generatedBashCode = dashdash.bashCompletionFromOptions({
        name: 'npmlinkup',
        options: cmd_line_opts_1.default,
        includeHidden: true
    });
    console.log(generatedBashCode);
    process.exit(0);
}
if (!root) {
    console.error(' => NPM-Link-Up => You do not appear to be within an NPM project (no package.json could be found).\n' +
        ' => Your present working directory is =>\n' + chalk.magenta.bold(cwd));
    process.exit(1);
}
var pkg, conf;
try {
    pkg = require(path.resolve(root + '/package.json'));
}
github sumanjs / suman / lib / parse-cmd-line-opts / parse-opts.js View on Github external
process.exit(constants.EXIT_CODES.BAD_COMMAND_LINE_OPTION);
}
if (opts.help) {
    process.stdout.write('\n');
    var help = parser.help({ includeEnv: true }).trimRight();
    console.log('usage: suman [file/dir] [OPTIONS]\n\n'
        + chalk.magenta('options:') + '\n'
        + help);
    process.stdout.write('\n');
    process.exit(0);
}
if (opts.completion) {
    console.log('\n');
    console.log(chalk.cyan(' => The following output can be used for bash completion with the suman executable.'));
    console.log(chalk.cyan(' => However, not that this is already available by using suman-clis.sh.'));
    var bashCompletionData = dashdash.bashCompletionFromOptions({
        name: 'suman',
        options: suman_options_1.options
    });
    console.log(bashCompletionData);
    process.exit(0);
}
if (opts.concurrency) {
    assert(typeof opts.concurrency === 'number', '--concurrency value must be a positive integer');
    assert(opts.concurrency !== 0, '--concurrency value must be a positive integer');
}
if (opts.fforce) {
    opts.force = true;
}
if (opts.per) {
    opts.watch_per = opts.per;
}
github ORESoftware / npm-link-up / lib / commands / basic / index.ts View on Github external
let help = parser.help({includeEnv: true}).trimRight();
  console.log('usage: nlu [OPTIONS]\n' + 'options:\n' + help);
  console.log();
  log.info('To get help for "nlu init", use:', chalk.blueBright.bold('nlu init --help'));
  log.info('To get help for "nlu run", use:', chalk.blueBright.bold('nlu run --help'));
  log.info('To get help for "nlu run", use:', chalk.blueBright.bold('nlu add --help'));
  log.info('Etc.');
  process.exit(0);
}


if (opts.bash_completion) {

  const allOpts = nluUtils.flattenDeep([addOpts, initOpts, runOpts, options]);

  let generatedBashCode = dashdash.bashCompletionFromOptions({
    name: 'nlu',
    options: allOpts,
    includeHidden: false
  });

  console.log(generatedBashCode);
  process.exit(0);
}


log.warn(chalk.bold.italic('No command line option was recognized.'));
log.warn(chalk.gray('Perhaps you meant to use one of these commands instead:', chalk.gray.bold(commands.join(', '))));
process.exit(1);

dashdash

A light, featureful and explicit option parsing library.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis