How to use the commander.on function in commander

To help you get started, we’ve selected a few commander 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 c9s / typeloy / bin / typeloy.ts View on Github external
.action( (env, options) => {
    let config = readConfig(prog.config);
    let actions = new BaseAction(config);
    actions.init();
  });


/*
// handling undefined command
prog.command('*')
  .action(function(env){
    console.log('deploying "%s"', env);
  });
*/

prog.on('--help', function(){
  /*
  console.log('  Examples:');
  console.log('');
  console.log('    $ custom-help --help');
  console.log('    $ custom-help -h');
  console.log('');
  */
});
prog.parse(process.argv);

// vim:sw=2:ts=2:sts=2:et:filetype=typescript:
github parcel-bundler / parcel / src / core / parcel / src / cli.js View on Github external
'--log-level ',
    'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
    /^([0-3])$/
  )
  .option('--cache-dir 
github howardengelhart / smoketail / bin / smoketail.js View on Github external
.option('-c, --credentials ', 'Profile name from ~/.aws/credentials ini.')
    .option('-i, --interleaved', 'Interleave the log results. (auto on if using -f).')
    .option('-f, --follow', 'When at the end of the logstream, ' +
        'poll for more messages.')
    .option('-p, --pattern 
github DivanteLtd / storefront-api / scripts / mage2vs.js View on Github external
importCmsBlocksPromise().then(() => {
                        console.log('Done! Bye Bye!')
                        process.exit(0)
                      })
                    })
                  })
                })
              })
            })
          })
        })
      })
    })
  });

program
  .on('command:*', () => {
    console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
    process.exit(1);
  });

program
  .parse(process.argv)

process.on('unhandledRejection', (reason, p) => {
  console.log('Unhandled Rejection at: Promise ', p, ' reason: ', reason)
})

process.on('uncaughtException', (exception) => {
  console.log(exception)
})
github alexpopdev / underscorejs-examples / advanced-topics / es6-examples / node_modules / babel / lib / babel / index.js View on Github external
var desc = [];
  if (option.deprecated) desc.push("[DEPRECATED] " + option.deprecated);
  if (option.description) desc.push(option.description);

  commander.option(arg, desc.join(" "));
});

commander.option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx]");
commander.option("-w, --watch", "Recompile files on changes");
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-D, --copy-files", "When compiling a directory copy over non-compilable files");
commander.option("-q, --quiet", "Don't log anything");

commander.on("--help", function () {
  var outKeys = function outKeys(title, obj) {
    console.log("  " + title + ":");
    console.log();

    each(keys(obj).sort(), function (key) {
      if (key[0] === "_") return;

      if (obj[key].metadata && obj[key].metadata.optional) key = "[" + key + "]";

      console.log("    - " + key);
    });

    console.log();
  };

  outKeys("Transformers", transform.pipeline.transformers);
github SpencerCDixon / redux-cli / src / cli / redux-generate.js View on Github external
import commander from 'commander';
import { version } from '../version';
import Generate from '../sub-commands/generate';
import minimist from 'minimist';

const subCommand = new Generate();

commander.on('--help', () => {
  subCommand.printUserHelp();
});

commander
  .version(version())
  .arguments(' [entity name]')
  .option('-v, --verbose', 'Turn debug mode on')
  .option('-d, --dry-run', 'Do not generate files and show what files will be created')
  .description('generates code based off a blueprint')
  .action((blueprintName, entityName, command) => {
    const debug = command.verbose;
    const dryRun = command.dryRun;
    const rawArgs = command.rawArgs;
    const options = minimist(rawArgs.slice(2));

    const cliArgs = {
github Galooshi / import-js / lib / importjs.js View on Github external
initializeLogging.parentPid = parentPid;
    daemon(parentPid, pathToLogFile);
  });

program
  .command('cachepath')
  .description('show path to cache file')
  .action(() => {
    stdoutWrite(new Configuration('importjs').get('cacheLocation'));
  });

program.command('logpath').description('show path to log file').action(() => {
  stdoutWrite(pathToLogFile);
});

program.on('--help', () => {
  const examples = [
    'word someModule path/to/file.js',
    'search someModule* path/to/file.js',
    'fix path/to/file.js',
    'rewrite --overwrite path/to/file.js',
    'add \'{ "foo": "path/to/foo", "bar": "path/to/bar" }\' path/to/file.js',
    'goto someModule path/to/file.js',
    'cachepath',
    'logpath',
    'start --parent-pid=12345',
  ];

  stdoutWrite('  Examples:');
  stdoutWrite('');
  examples.forEach((example: string) => {
    stdoutWrite(`    $ importjs ${example}`);
github bitwarden / directory-connector / src / program.ts View on Github external
process.env.BW_PRETTY = 'true';
        });

        program.on('option:raw', () => {
            process.env.BW_RAW = 'true';
        });

        program.on('option:quiet', () => {
            process.env.BW_QUIET = 'true';
        });

        program.on('option:response', () => {
            process.env.BW_RESPONSE = 'true';
        });

        program.on('command:*', () => {
            writeLn(chalk.redBright('Invalid command: ' + program.args.join(' ')), false, true);
            writeLn('See --help for a list of available commands.', true, true);
            process.exitCode = 1;
        });

        program.on('--help', () => {
            writeLn('\n  Examples:');
            writeLn('');
            writeLn('    bwdc login');
            writeLn('    bwdc test');
            writeLn('    bwdc sync');
            writeLn('    bwdc last-sync');
            writeLn('    bwdc config server https://bw.company.com');
            writeLn('    bwdc update');
            writeLn('', true);
        });
github ostdotcom / ost-view / executables / GlobalAggregatorCron.js View on Github external
OSTBase = require('@ostdotcom/base'),
  coreConstants = require(rootPrefix + '/config/coreConstants'),
  logger = require(rootPrefix + '/lib/logger/customConsoleLogger'),
  responseHelper = require(rootPrefix + '/lib/formatter/response'),
  errorConfig = basicHelper.getErrorConfig();

const InstanceComposer = OSTBase.InstanceComposer;

require(rootPrefix + '/app/services/home/GlobalAggregator');

program
  .option('--chainId ', 'Chain id')
  .option('--configFile ', 'OST View config strategy absolute file path')
  .parse(process.argv);

program.on('--help', function() {
  logger.log('');
  logger.log('  Example:');
  logger.log('');
  logger.log("    node executables/GlobalAggregatorCron.js --configFile './config.json'");
  logger.log('');
  logger.log('');
});

class GlobalAggregator {
  constructor(params) {
    const oThis = this;
    oThis.config = require(params.configFile);
  }

  /**
   * Main performer method for the class.
github gorangajic / workmode / index.js View on Github external
.option('stop', "Disbles the black list.")
    .option('add [domain]', "Adds the domain to the black list.")
    .option('remove [index|domain]', ["Removes one the domain at the given index. ",
                                      "If no parameter is passed, displays the blacklist ",
                                      "and prompts for one."].join())
    .option('list', 'Displays the blacklist.');

  program.on('stop', function() {
    var error, msg = self.stop();
    if (!(error = parseError(msg))) {
      self.writeHosts();
    }
    puts(error || msg);
  });

  program.on('start', function() {
    var error, msg = self.start();
    if (!(error = parseError(msg))) {
      self.writeHosts();
    }
    puts(error || msg);
  });

  program.on('status', function() {
    if (self.list.length === 0) {
      puts('The blacklist is empty.');
    } else if (self.enabled()) {
      puts('Workmode is enabled.');
    } else {
      puts('Workmode is disabled.');
    }
  });