The args processor davglass uses in his CLI tools

npm install davargs
58 downloads in the last day
3 576 downloads in the last week
5 124 downloads in the last month


This is the arguments processor that I use in my CLI tools. It is a very small wrapper around nopt to help with setting up defaults and sanatizing a little logic.


var davargs = require('davargs');

    known: {
        foo: Boolean,
        baz: Boolean,
        bar: String
    shorts: {
        b: ['--bar']
    on: ['foo'],
    off: ['baz']

var options = davargs.parse(process.argv);

{ foo: true, help: false, version: false, baz: false }


The init function allows for this config

  • known - The known object to use with nopt
  • shorts - The shorts object to use with nopt
  • on - An array of keys for the known object to set to true by default
  • off - An array of keys for the known object to set to false by default

There is also a provided has method to check to see if an argument has been passed on the cli reguardless of whether it's true or false. Useful when passing arguments down a layer to a subprocess.

build status

Build Status

node badge


npm loves you