Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


Command line options parser

Subscribe to updates I use bossy

Statistics on bossy

Number of watchers on Github 41
Number of open issues 1
Average time to close an issue 24 days
Main language JavaScript
Average time to merge a PR about 17 hours
Open pull requests 0+
Closed pull requests 2+
Last commit over 2 years ago
Repo Created almost 6 years ago
Repo Last Updated over 2 years ago
Size 76 KB
Organization / Authorhapijs
Page Updated
Do you use bossy? Leave a review!
View bossy activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating bossy for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


Command line options parser.

Build Status

Lead Maintainer - sericaia


var Bossy = require('bossy');

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

var args = Bossy.parse(definition);

if (args instanceof Error) {

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

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


parse(definition, [options])

Expects a bossy definition object and will return the parsed process.argv arguments provided. If there is an error then the return value will be an instanceof Error.

Options accepts the following keys:

  • argv - custom argv array value. Defaults to process.argv.

usage(definition, [usage], [options])

Format a bossy definition object for display in the console. If usage is provided the returned value will include the usage value formatted at the top of the message.

Options accepts the following keys:

  • colors - Determines if colors are enabled when formatting usage. Defaults to whatever TTY supports.

Definition Object

The definition object should be structured with each object key representing the short form of an available command line argument. Each argument key supports the following properties:

  • alias: A string or array of strings that can also be used as the argument name. For example:

    h: {
    alias: 'help'
  • type: Available types are: boolean, range, number, string, and help. Defaults to string.

    help is a special type that allows the switch to be executed even though other paramters are required. Use case is to display a help message and quit. This will bypass all other errors, so be sure to capture it. It behaves like a boolean.

  • multiple : Boolean to indicate if the same argument can be provided multiple times. If true, the parsed value will always be an array of type's. Defaults to false.

  • description: Description message that will be returned with usage information.

  • require: Boolean to indicate if the argument is required. Defaults to false

  • default: A default value to assign to the argument if its not provided as an argument.

  • valid: A value or array of values that the argument is allowed to equal.

bossy open issues Ask a question     (View All Issues)
  • almost 4 years Unable to parse values that begin with -
bossy list of languages used
Other projects in JavaScript