How to use the commander.help 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 sane / sane / src / cli.js View on Github external
// and then create all the one that don't exist on either side and the rest make sure they are the same.
  // For all attributes that only exist on the sails side (e.g. email) a substitute has to be found
  // Think if it makes sense to have some minimal settings (flags, or .sanerc file?) to ignore certain models/attrinutes
  //   .command('sync [modelName]')
  //   .alias('s')
  //   .description('Syncs the client and server models.')
  //   .action(function (modelName){ commands.sync(modelName); });

  program.on('--help', function (){
    console.log('version: ' + version);
  });

  program.parse(args);

  if (!program.args.length || program.args[0] === 'help') {
    program.help();
  }

};
github ta2edchimp / opt-cli / bin / index.js View on Github external
.reduce(
        ( accumulator, key ) => {
          accumulator[ key ] = process.env[ key ];

          return accumulator;
        },
        {}
      ),
    alteredEnvPath = null;

  // invalid arguments: ("in" OR "out" have to be specified, as well es "exec") OR "list" has to be requested
  if (
    ( ( program.in && program.out ) || ( !program.in && !program.out ) || !program.exec ) &&
    !program.list
  ) {
    program.help();

    return;
  }

  if ( program.verbose ) {
    info = console.log; // eslint-disable-line no-console
  }

  if ( program.in && !opt.testOptIn( program.in ) ) {
    info( 'Not opted-in to "' + program.in + '".' );

    return;
  }

  if ( program.out && opt.testOptOut( program.out ) ) {
    info( 'Opted-out of "' + program.out + '".' );
github okwme / dapp-scratch / bin / dapp-scratch.js View on Github external
function getContract (path) {
    if (!fs.existsSync(path)) {
        path = './contracts/' + path
        if (!fs.existsSync(path)) {
            path  = path + '.sol'
            if (!fs.existsSync(path)) {
                console.log(colors.red('No Contract found'));
                commander.help()
                process.exit(1);
            }
        }
    }
    return path
}
function getABI (path) {
github kenperkins / coreos-cluster-cli / index.js View on Github external
function terminate(reason, help) {
  console.error(colors.red(reason));
  if (help) {
    program.help();
  }
  process.exit(1);
}
github microsoft / PowerBI-Cli / lib / cli-get-datasets.ts View on Github external
.option('-w, --workspace ', 'The Power BI workspace')
        .option('-k, --accessKey ', 'The Power BI workspace collection access key')
        .option('-b --baseUri [baseUri]', 'The base uri to connect to');

    program.on('--help', function () {
        console.log('  Examples:');
        console.log('');
        console.log('    $ powerbi get-datasets -c  -w  -k ');
    });

    program.parse(process.argv);

    let settings = config.merge(program);

    if (!(settings.collection && settings.accessKey && settings.workspace)) {
        program.help();
    } else {
        try {
            let credentials = new msrest.TokenCredentials(settings.accessKey, 'AppKey');
            let client = new powerbi.PowerBIClient(credentials, settings.baseUri, null);

            client.datasets.getDatasets(settings.collection, settings.workspace, (err, result) => {
                if (err) {
                    return cli.error(err);
                }
                
                let datasets = result.value;

                if (datasets.length === 0) {
                    return cli.warn('No datasets found within workspace: %s', settings.workspace);
                }
github ProofSuite / togen-cli / lib / cmd.js View on Github external
process(args) {
    this.init();
    this.console();
    this.configure();
    this.assemble();
    this.compile();
    this.deploy();
    this.help();
    this.unknown();

    if (!process.argv.slice(2).length) program.help()
    program.parse(args);
  }
github cssinjs / cli / bin / jss.js View on Github external
.action(function onConvert(src) {
    if (src) console.log(convert(src))
    else if (program.multiline) {
      console.log('Input source:')
      multilinePrompt((src) => {
        try {
          console.log(convert(src) + '\n')
        } catch (err) {
          console.log(err.message)
        }
        onConvert()
      })
    } else {
      program.help()
    }
  })
github mseminatore / TeslaJS / samples / navRequest.js View on Github external
function sampleMain(tjs, options) {
    var subject = program.args[0];
    var text = program.args[1];
    var locale = program.args[1] || "en-US";

    if (!subject || !text) {
        console.log("\n");
        program.help();
    }

    tjs.navigationRequest(options, subject, text, locale, function (err, result) {
        if (err) {
            console.error("\nnavigationRequest command: " + "Failed!".red + "\n");
        } else {
            if (result.result) {
                console.log("\nnavigationRequest command: " + "Succeeded".green + "\n");
            } else {
                console.log("\nnavigationRequest command: " + "Failed!".red + "\n");
                console.log("Reason: " + result.reason.red + "\n");
            }
        }
    });
}
github charlieschwabacher / gestalt / packages / gestalt-cli / src / index.js View on Github external
.action(async name => {
    if (!name) {
      commander.help('init');
    }
    await init(name);
    process.exit(0);
  });
github happylinks / gqlint / bin / gqlint.js View on Github external
function runProgramOnStdIn() {
  if (isTty(process.stdin)) {
    program.help();
  }
  captureStdIn(handleInputSuccess);
}