How to use the @hapi/bossy.parse function in @hapi/bossy

To help you get started, we’ve selected a few @hapi/bossy 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 hapipal / hpal-debug / lib / commands / curl.js View on Github external
const actualArgs = argv.slice(0, matchOn.length).join(' ');

        // Ensuring a route avoids a case like "hpal run debug:curl -h" displaying here,
        // registering the help flag as a potential route id.  And other bad/odd cases
        // where the user is asking for help about a specific route, and the route didn't exist.

        if (route) {
            // If there's a route, then there must have been actualArgs that specified it
            usage += '\n\n' + colors.bold(`hpal run debug:curl ${actualArgs} [options]`);
        }

        return Bossy.usage(definition, usage, { colors: options.colors });
    };

    const parameters = Bossy.parse(definition, { argv });

    if (parameters instanceof Error) {
        throw new DisplayError(getUsage() + '\n\n' + colors.red(parameters.message));
    }

    if (parameters.help) {
        output(getUsage());
        return null;
    }

    if (matchOn.length === 0) {
        throw new DisplayError(getUsage() + '\n\n' + colors.red('No route specified'));
    }

    // Bossy gives false specifically for missing boolean
    // params— we'll choose to just omit those instead.
github hapijs / joi / benchmarks / bench.js View on Github external
alias: 'save',
        type: 'string'
    },
    t: {
        alias: 'threshold',
        type: 'number',
        default: 10
    },
    j: {
        alias: 'joi',
        type: 'string',
        default: '..'
    }
};

const args = Bossy.parse(definition);

let compare;
if (args.compare) {
    try {
        compare = JSON.parse(Fs.readFileSync(args.compare, 'utf8'));
    }
    catch (e) {
        // Ignore error
    }
}

const formats = {
    number: D3.format(',d'),
    percentage: D3.format('.2f'),
    integer: D3.format(',')
};
github hapijs / lab / lib / cli.js View on Github external
linter: 'eslint',
        'lint-fix': false,
        'lint-errors-threshold': 0,
        'lint-warnings-threshold': 0,
        paths: ['test'],
        reporter: 'console',
        shuffle: false,
        silence: false,
        'silent-skips': false,
        sourcemaps: false,
        'context-timeout': 0,
        timeout: 2000,
        verbose: false
    };

    const argv = Bossy.parse(definition);

    if (argv instanceof Error) {
        console.error(Bossy.usage(definition, 'lab [options] [path]'));
        console.error('\n' + argv.message);
        process.exit(1);
    }

    if (argv.help) {
        console.log(Bossy.usage(definition, 'lab [options] [path]'));
        process.exit(0);
    }

    if (argv.version) {
        console.log(Pkg.version);
        process.exit(0);
    }
github hapipal / hpal-debug / lib / commands / routes.js View on Github external
type: 'string',
            alias: 'H',
            multiple: true,
            description: 'Hide specific columns. May be listed multiple times.',
            valid: colNames
        },
        show: {
            type: 'string',
            alias: 's',
            multiple: true,
            description: 'Show specific columns. May be listed multiple times.',
            valid: colNames
        }
    };

    const parameters = Bossy.parse(definition, { argv });
    const getUsage = () => {

        const usage = [
            'hpal run debug:routes [options]',
            'hpal run debug:routes  [options]',
            'hpal run debug:routes [] 
github cjihrig / belly-button / lib / cli.js View on Github external
module.exports.run = async function (argv, callback) {
  const args = Bossy.parse(cliArgs, { argv });

  if (args instanceof Error) {
    return callback(new Error(Bossy.usage(cliArgs, args.message)));
  }

  const configFile = args.config;
  const globs = args.input;
  const ignore = args.ignore;
  const fix = args.fix;
  const cache = args.cache;
  const cwd = args.pwd || process.cwd();

  try {
    const files = await getFilesToLint({ globs, ignore, cwd });
    const result = lintFiles({ configFile, fix, cache, files });
    const exitCode = +!!result.errorCount;

@hapi/bossy

Command line options parser

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis

Popular @hapi/bossy functions