bossy

Command line options parser.

Latest Version: 6.0.1
hapi-family
Installation:

npm: npm install @hapi/bossy

yarn: yarn add @hapi/bossy

Module Status:
Version License Node Dependencies CI
6.0.1
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status
5.1.0
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status

Usage

const Bossy = require('@hapi/bossy');

const definition = {
    h: {
        description: 'Show help',
        alias: 'help',
        type: 'boolean'
    },
    n: {
        description: 'Show your name',
        alias: 'name'
    }
};

const args = Bossy.parse(definition);

if (args instanceof Error) {
    console.error(args.message);
    return;
}

if (args.h || !args.n) {
    console.log(Bossy.usage(definition, 'hello -n <name>'));
    return;
}

console.log('Hello ' + args.n);
console.log('Hello ' + args.name);