How to use the args.showHelp function in args

To help you get started, we’ve selected a few args 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 interactivethings / catalog / packages / cli / src / bin / catalog.ts View on Github external
import args from "args";

args
  .command("start", "Starts the Catalog server")
  .command("build", "Builds a Catalog static site");

args.parse(process.argv);

if (!args.sub.length) {
  // no commands
  args.showHelp();
}
github nodesource / nscm / bin / nscm.js View on Github external
.command('report', 'Get a report of your packages', report, ['r'])
  .command('verify', 'Verify if all packages are certified', verify)
  .command('whitelist', 'Whitelist your packages', ['w'])
  .command('config', 'Configure nscm options', ['c'])
  .command('signin', 'Sign in to nscm', signin, ['s', 'login'])
  .command('signout', 'Sign out of nscm', signout, ['o', 'logout'])

const flags = args.parse(process.argv, {
  usageFilter: tools.usageFilter
})

// Call report by default
if (!args.sub.length) {
  report(['report', 'r'], [], flags)
} else if (commands.indexOf(args.sub[0]) === -1) {
  args.showHelp()
}
github luisfarzati / docker-lambda-api-server / bin / index.js View on Github external
var DEFAULT_PORT = 3000
var DEFAULT_FUNCTION_PATH = '.'
var AWS_LAMBDA_API_URL_REGEX = /^\/\d{4}-\d{2}-\d{2}\/functions\/(.+?)\/invocations/

args
  .option(['h', 'help'], 'Show usage information')
  .option(['p', 'port'], 'Port on which the API server will be running', DEFAULT_PORT)
  .option(['P', 'path'], 'Path to the function handler scripts', DEFAULT_FUNCTION_PATH)
  .option(['f', 'file'], 'AWS SAM template file')
  .option(['v', 'verbose'], 'Verbose output')

var opts = args.parse(process.argv, { help: false, version: false })

if (!opts.file) {
  return args.showHelp()
}

var functionsDir = path.resolve(process.cwd(), opts.path)
var doc = yaml.safeLoad(fs.readFileSync(opts.file, 'utf8'))

// TODO: improve -- quick & dirty filtering
var functions = Object.keys(doc.Resources)
  .filter(name => 
    doc.Resources[name].Type === 'AWS::Serverless::Function'
    &&
    doc.Resources[name].Properties.Runtime.indexOf('nodejs') >= 0
  )
  .reduce((obj, name) => {
    obj[name] = doc.Resources[name].Properties.Handler
    return obj
  }, {})
github direct-adv-interfaces / mocha-headless-chrome / lib / cli.js View on Github external
.option('height', 'Viewport height', undefined, parseInt)
    .option('executablePath', 'Chrome executable path', undefined, String)
    .option('visible', 'Show Chrome window', undefined, Boolean)
    .example('mocha-headless-chrome -f test.html', 'Run tests on the "test.html" page')
    .example('mocha-headless-chrome -f http://localhost:8080', 'Run tests on the remote page')
    .example('mocha-headless-chrome -f test.html -a no-sandbox -a disable-setuid-sandbox', 'Pass the Chrome arguments')
    .example('mocha-headless-chrome -f test.html -r nyan', 'Output test result using "nyan" reporter');

let cfg = args.parse(process.argv, {
    name: 'mocha-headless-chrome',
    version: false,
    help: false
});

if (cfg.help) {
    args.showHelp();
}

runner(cfg)
    .then(obj => {
        const getContent = (obj) => obj ? JSON.stringify(obj) : '';

        cfg.out && writeFile(cfg.out, getContent(obj.result));
        cfg.coverage && writeFile(cfg.coverage, getContent(obj.coverage));

        if (obj.result.stats.failures) {
            throw 'Tests fails';
        }
    })
    .catch(err => {
        console.error(err);
        process.exit(1);
github nodesource / nscm / bin / nscm-config.js View on Github external
const chalk = require('chalk')
const config = require('../commands/config')
const tools = require('../lib/tools')

args
  .command('set', `Sets a configuration option ${chalk.gray('(eg: set depth 2)')}`, config.set, ['s'])
  .command('get', `Gets a configuration option ${chalk.gray('(eg: get registry)')}`, config.get, ['g'])
  .command('delete', `Deletes a configuration option ${chalk.gray('(eg: delete token)')}`, config.del, ['d'])
  .command('list', 'List all configuration options', config.list, ['l'])
  .command('reset', 'Reset all configuration options', config.reset, ['r'])
  .parse(process.argv, {
    usageFilter: tools.usageFilter
  })

if (!args.sub.length) {
  args.showHelp()
}