{
  "name": "yargs",
  "version": "1.3.1",
  "description": "Light-weight option parsing with an argv hash. No optstrings attached.",
  "main": "./index.js",
  "dependencies": {},
  "devDependencies": {
    "hashish": "*",
    "mocha": "*",
    "chai": "*"
  },
  "scripts": {
    "test": "mocha -R nyan"
  },
  "repository": {
    "type": "git",
    "url": "http://github.com/chevex/yargs.git"
  },
  "keywords": [
    "argument",
    "args",
    "option",
    "parser",
    "parsing",
    "cli",
    "command"
  ],
  "author": {
    "name": "Alex Ford",
    "email": "Alex.Ford@CodeTunnel.com",
    "url": "http://CodeTunnel.com"
  },
  "license": "MIT/X11",
  "engine": {
    "node": ">=0.4"
  },
  "readme": "yargs\n========\n\nYargs be a node.js library fer hearties tryin' ter parse optstrings against their will where even the boo box be not enough to coerce them. This here module is fer scallywags lookin' ter plunder all the sunken -shipz of their --treasures thru program usage but be tired of optstrings disincling to acquiesce to yer requests.\n\nWith yargs, ye be havin' a map that leads straight to yer treasure! Treasure of course, being a simple option hash.\n\n[![Build Status](https://travis-ci.org/chevex/yargs.png)](https://travis-ci.org/chevex/yargs)\n[![Dependency Status](https://gemnasium.com/chevex/yargs.png)](https://gemnasium.com/chevex/yargs)\n[![NPM version](https://badge.fury.io/js/yargs.png)](http://badge.fury.io/js/yargs)\n\n> ~~NOTE: Yargs is a fork of [optimist](https://github.com/substack/node-optimist) by [substack (James Halliday)](https://github.com/substack). It is obvious that substack is stretched pretty thin maintaining over 300 modules on npm at the time of this writing. So rather than complain in the project issue tracker I thought I'd just pick up the torch and maintain a proper fork. Currently the project is totally backward compatible with optimist but this may change in the future (if it does I will update this notice to inform you of this). For now though, enjoy optimist with about 5 months worth of fixes and updates rolled in, most of them pulled from optimist's own [stale pull requests](https://github.com/substack/node-optimist/pulls).~~\n\n> UPDATE: Yargs is now the official successor to optimist. Please feel free to submit issues and pull requests. While I personally don't have the time to pore over all the issues and fix all of them on a regular basis, I'm more than happy to look over pull requests, test them, and merge them in. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/chevex/yargs/issues) :)\n\nexamples\n========\n\nWith yargs, the options be just a hash! No optstrings be attached.\n-------------------------------------------------------------------\n\nxup.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs').argv;\n\nif (argv.rif - 5 * argv.xup > 7.138) {\n    console.log('Plunder more riffiwobbles!');\n}\nelse {\n    console.log('Drop the xupptumblers!');\n}\n````\n\n***\n\n    $ ./xup.js --rif=55 --xup=9.52\n    Plunder more riffiwobbles!\n    \n    $ ./xup.js --rif 12 --xup 8.1\n    Drop the xupptumblers!\n\n![Joe was one optimistic pirate.](http://i.imgur.com/4WFGVJ9.png)\n\nBut don' walk the plank jus' yet! Ther' be more! Ye can do short options:\n-------------------------------------------------\n \nshort.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs').argv;\nconsole.log('(%d,%d)', argv.x, argv.y);\n````\n\n***\n\n    $ ./short.js -x 10 -y 21\n    (10,21)\n\nAnd gold doubooleans, both long an' short (an' grouped!):\n----------------------------------\n\nbool.js:\n\n````javascript\n#!/usr/bin/env node\nvar util = require('util');\nvar argv = require('yargs').argv;\n\nif (argv.s) {\n    util.print(argv.fr ? 'Le perroquet dit: ' : 'The parrot says: ');\n}\nconsole.log(\n    (argv.fr ? 'couac' : 'squawk') + (argv.p ? '!' : '')\n);\n````\n\n***\n\n    $ ./bool.js -s\n    The parrot says: squawk\n    \n    $ ./bool.js -sp\n    The parrot says: squawk!\n\n    $ ./bool.js -sp --fr\n    Le perroquet dit: couac!\n\nAnd non-hyphenated options too! Just use `argv._`!\n-------------------------------------------------\n \nnonopt.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs').argv;\nconsole.log('(%d,%d)', argv.x, argv.y);\nconsole.log(argv._);\n````\n\n***\n\n    $ ./nonopt.js -x 6.82 -y 3.35 rum\n    (6.82,3.35)\n    [ 'rum' ]\n    \n    $ ./nonopt.js \"me hearties\" -x 0.54 yo -y 1.12 ho\n    (0.54,1.12)\n    [ 'me hearties', 'yo', 'ho' ]\n\nYargs even counts yer gold doubooleans!\n----------------------------------------------------------------------\n\ncount.js\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .count('verbose')\n    .alias('v', 'verbose')\n    .argv;\n\nVERBOSE_LEVEL = argv.verbose;\n\nfunction WARN()  { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); }\nfunction INFO()  { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); }\nfunction DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); }\n\nWARN(\"Showing only important stuff\");\nINFO(\"Showing semi-mportant stuff too\");\nDEBUG(\"Extra chatty mode\");\n````\n\n***\n    $ node count.js\n    Showing only important stuff\n\n    $ node count.js -v\n    Showing only important stuff\n    Showing semi-important stuff too\n\n    $ node count.js -vv\n    Showing only important stuff\n    Showing semi-important stuff too\n    Extra chatty mode\n\n    $ node count.js -v --verbose\n    Showing only important stuff\n    Showing semi-important stuff too\n    Extra chatty mode\n\nTell yer friends how ter use yer options and make demands from yer enemies.\n-------------------------------------------------\n\ndivide.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .usage('Usage: $0 -x [num] -y [num]')\n    .demand(['x','y'])\n    .argv;\n\nconsole.log(argv.x / argv.y);\n````\n\n***\n \n    $ ./divide.js -x 55 -y 11\n    5\n    \n    $ node ./divide.js -x 4.91 -z 2.51\n    Usage: node ./divide.js -x [num] -y [num]\n\n    Options:\n      -x  [required]\n      -y  [required]\n\n    Missing required arguments: y\n\nAfter yer demands have been met, demand more! Ask for non-hypenated arguments!\n-----------------------------------------\n\ndemand_count.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .demand(2)\n    .argv;\nconsole.dir(argv)\n````\n\n***\n\n\t$ ./demand_count.js a\n\tNot enough arguments, expected 2, but only found 1\n\t$ ./demand_count.js a b\n\t{ _: [ 'a', 'b' ], '$0': 'node ./demand_count.js' }\n\t$ ./demand_count.js a b c\n\t{ _: [ 'a', 'b', 'c' ], '$0': 'node ./demand_count.js' }\n\nEVEN MORE SHIVER ME TIMBERS!\n------------------\n\ndefault_singles.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .default('x', 10)\n    .default('y', 10)\n    .argv\n;\nconsole.log(argv.x + argv.y);\n````\n\n***\n\n    $ ./default_singles.js -x 5\n    15\n\ndefault_hash.js:\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .default({ x : 10, y : 10 })\n    .argv\n;\nconsole.log(argv.x + argv.y);\n````\n\n***\n\n    $ ./default_hash.js -y 7\n    17\n\nAnd if ye really want ter get all descriptive about it...\n---------------------------------------------------------\n\nboolean_single.js\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .boolean('v')\n    .argv\n;\nconsole.dir(argv.v);\nconsole.dir(argv._);\n````\n\n***\n\n    $ ./boolean_single.js -v \"me hearties\" yo ho\n    true\n    [ 'me hearties', 'yo', 'ho' ]\n    \n\nboolean_double.js\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .boolean(['x','y','z'])\n    .argv\n;\nconsole.dir([ argv.x, argv.y, argv.z ]);\nconsole.dir(argv._);\n````\n\n***\n\n    $ ./boolean_double.js -x -z one two three\n    [ true, false, true ]\n    [ 'one', 'two', 'three' ]\n\nYargs is here ter help ye...\n---------------------------\n\nYe can describe parameters fer help messages and set aliases. Yargs figures\nout how ter format a handy help string automatically.\n\nline_count.js\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .usage('Count the lines in a file.\\nUsage: $0')\n    .example('$0 -f', 'count the lines in the given file')\n    .demand('f')\n    .alias('f', 'file')\n    .describe('f', 'Load a file')\n    .argv\n;\n\nvar fs = require('fs');\nvar s = fs.createReadStream(argv.file);\n\nvar lines = 0;\ns.on('data', function (buf) {\n    lines += buf.toString().match(/\\n/g).length;\n});\n\ns.on('end', function () {\n    console.log(lines);\n});\n````\n\n***\n\n    $ node line_count.js\n    Count the lines in a file.\n    Usage: node ./line_count.js\n\n    Examples:\n      node ./line_count.js -f   count the lines in the given file\n\n    Options:\n      -f, --file  Load a file  [required]\n\n    Missing required arguments: f\n\n    $ node line_count.js --file line_count.js \n    20\n    \n    $ node line_count.js -f line_count.js \n    20\n\nmethods\n=======\n\nBy itself,\n\n````javascript\nrequire('yargs').argv\n`````\n\nwill use `process.argv` array to construct the `argv` object.\n\nYou can pass in the `process.argv` yourself:\n\n````javascript\nrequire('yargs')([ '-x', '1', '-y', '2' ]).argv\n````\n\nor use .parse() to do the same thing:\n\n````javascript\nrequire('yargs').parse([ '-x', '1', '-y', '2' ])\n````\n\nThe rest of these methods below come in just before the terminating `.argv`.\n\n.alias(key, alias)\n------------------\n\nSet key names as equivalent such that updates to a key will propagate to aliases\nand vice-versa.\n\nOptionally `.alias()` can take an object that maps keys to aliases.\nEach key of this object should be the canonical version of the option, and each\nvalue should be a string or an array of strings.\n\n.default(key, value)\n--------------------\n\nSet `argv[key]` to `value` if no option was specified on `process.argv`.\n\nOptionally `.default()` can take an object that maps keys to default values.\n\n.demand(key, [msg | boolean])\n-----------------------------\n.require(key, [msg | boolean])\n------------------------------\n.required(key, [msg | boolean])\n-------------------------------\n\nIf `key` is a string, show the usage information and exit if `key` wasn't\nspecified in `process.argv`.\n\nIf `key` is a number, demand at least as many non-option arguments, which show\nup in `argv._`.\n\nIf `key` is an Array, demand each element.\n\nIf a `msg` string is given, it will be printed when the argument is missing,\ninstead of the standard error message. This is especially helpful for the non-option arguments in `argv._`.\n\nIf a `boolean` value is given, it controls whether the option is demanded;\nthis is useful when using `.options()` to specify command line parameters.\n\n.requiresArg(key)\n-----------------\n\nSpecifies either a single option key (string), or an array of options that\nmust be followed by option values. If any option value is missing, show the\nusage information and exit.\n\nThe default behaviour is to set the value of any key not followed by an\noption value to `true`.\n\n.describe(key, desc)\n--------------------\n\nDescribe a `key` for the generated usage information.\n\nOptionally `.describe()` can take an object that maps keys to descriptions.\n\n.options(key, opt)\n------------------\n\nInstead of chaining together `.alias().demand().default()`, you can specify\nkeys in `opt` for each of the chainable methods.\n\nFor example:\n\n````javascript\nvar argv = require('yargs')\n    .options('f', {\n        alias : 'file',\n        default : '/etc/passwd',\n    })\n    .argv\n;\n````\n\nis the same as\n\n````javascript\nvar argv = require('yargs')\n    .alias('f', 'file')\n    .default('f', '/etc/passwd')\n    .argv\n;\n````\n\nOptionally `.options()` can take an object that maps keys to `opt` parameters.\n\n.usage(message, opts)\n---------------------\n\nSet a usage message to show which commands to use. Inside `message`, the string\n`$0` will get interpolated to the current script name or node command for the\npresent script similar to how `$0` works in bash or perl.\n\n`opts` is optional and acts like calling `.options(opts)`.\n\n.example(cmd, desc)\n-------------------\n\nGive some example invocations of your program. Inside `cmd`, the string\n`$0` will get interpolated to the current script name or node command for the\npresent script similar to how `$0` works in bash or perl.\nExamples will be printed out as part of the help message.\n\n.check(fn)\n----------\n\nCheck that certain conditions are met in the provided arguments.\n\n`fn` is called with two arguments, the parsed `argv` hash and an array of options and their aliases.\n\nIf `fn` throws or returns `false`, show the thrown error, usage information, and\nexit.\n\n.boolean(key)\n-------------\n\nInterpret `key` as a boolean. If a non-flag option follows `key` in\n`process.argv`, that string won't get set as the value of `key`.\n\nIf `key` never shows up as a flag in `process.arguments`, `argv[key]` will be\n`false`.\n\nIf `key` is an Array, interpret all the elements as booleans.\n\n.string(key)\n------------\n\nTell the parser logic not to interpret `key` as a number or boolean.\nThis can be useful if you need to preserve leading zeros in an input.\n\nIf `key` is an Array, interpret all the elements as strings.\n\n.config(key)\n------------\n\nTells the parser to interpret `key` as a path to a JSON config file. The file\nis loaded and parsed, and its properties are set as arguments.\n\n.wrap(columns)\n--------------\n\nFormat usage output to wrap at `columns` many columns.\n\n.strict()\n---------\n\nAny command-line argument given that is not demanded, or does not have a\ncorresponding description, will be reported as an error.\n\n.help([option, [description]])\n------------------------------\n\nAdd an option (e.g., `--help`) that displays the usage string and exits the\nprocess. If present, the `description` parameter customises the description of\nthe help option in the usage string.\n\nIf invoked without parameters, `.help` returns the generated usage string.\n\nExample:\n\n```\nvar yargs = require(\"yargs\")\n       .usage(\"$0 -operand1 number -operand2 number -operation [add|subtract]\");\nconsole.log(yargs.help());\n```\n\nLater on, ```argv``` can be retrived with ```yargs.argv```\n\n.version(version, option, [description])\n----------------------------------------\n\nAdd an option (e.g., `--version`) that displays the version number (given by the\n`version` parameter) and exits the process. If present, the `description`\nparameter customises the description of the version option in the usage string.\n\n.showHelpOnFail(enable, [message])\n----------------------------------\n\nBy default, yargs outputs a usage string if any error is detected. Use the\n`.showHelpOnFail` method to customize this behaviour. if `enable` is `false`,\nthe usage string is not output. If the `message` parameter is present, this\nmessage is output after the error message.\n\nline_count.js\n\n````javascript\n#!/usr/bin/env node\nvar argv = require('yargs')\n    .usage('Count the lines in a file.\\nUsage: $0')\n    .demand('f')\n    .alias('f', 'file')\n    .describe('f', 'Load a file')\n    .showHelpOnFail(false, \"Specify --help for available options\")\n    .argv;\n\n// etc.\n````\n\n***\n\n    $ node line_count.js --file\n    Missing argument value: f\n\n    Specify --help for available options\n\n.showHelp(fn=console.error)\n---------------------------\n\nPrint the usage data using `fn` for printing.\n\nExample:\n\n```\nvar yargs = require(\"yargs\")\n       .usage(\"$0 -operand1 number -operand2 number -operation [add|subtract]\");\nyargs.showHelp();\n```\n\nLater on, ```argv``` can be retrived with ```yargs.argv```\n\n.parse(args)\n------------\n\nParse `args` instead of `process.argv`. Returns the `argv` object.\n\n.argv\n-----\n\nGet the arguments as a plain old object.\n\nArguments without a corresponding flag show up in the `argv._` array.\n\nThe script name or node command is available at `argv.$0` similarly to how `$0`\nworks in bash or perl.\n\nparsing tricks\n==============\n\nstop parsing\n------------\n\nUse `--` to stop parsing flags and stuff the remainder into `argv._`.\n\n    $ node examples/reflect.js -a 1 -b 2 -- -c 3 -d 4\n    { _: [ '-c', '3', '-d', '4' ],\n      '$0': 'node ./examples/reflect.js',\n      a: 1,\n      b: 2 }\n\nnegate fields\n-------------\n\nIf you want to explicity set a field to false instead of just leaving it\nundefined or to override a default you can do `--no-key`.\n\n    $ node examples/reflect.js -a --no-b\n    { _: [],\n      '$0': 'node ./examples/reflect.js',\n      a: true,\n      b: false }\n\nnumbers\n-------\n\nEvery argument that looks like a number (`!isNaN(Number(arg))`) is converted to\none. This way you can just `net.createConnection(argv.port)` and you can add\nnumbers out of `argv` with `+` without having that mean concatenation,\nwhich is super frustrating.\n\nduplicates\n----------\n\nIf you specify a flag multiple times it will get turned into an array containing\nall the values in order.\n\n    $ node examples/reflect.js -x 5 -x 8 -x 0\n    { _: [],\n      '$0': 'node ./examples/reflect.js',\n        x: [ 5, 8, 0 ] }\n\ndot notation\n------------\n\nWhen you use dots (`.`s) in argument names, an implicit object path is assumed.\nThis lets you organize arguments into nested objects.\n\n     $ node examples/reflect.js --foo.bar.baz=33 --foo.quux=5\n     { _: [],\n       '$0': 'node ./examples/reflect.js',\n         foo: { bar: { baz: 33 }, quux: 5 } }\n\nshort numbers\n-------------\n\nShort numeric `head -n5` style argument work too:\n\n    $ node reflect.js -n123 -m456\n    { '3': true,\n      '6': true,\n      _: [],\n      '$0': 'node ./reflect.js',\n      n: 123,\n      m: 456 }\n\ninstallation\n============\n\nWith [npm](http://github.com/isaacs/npm), just do:\n\n    npm install yargs\n \nor clone this project on github:\n\n    git clone http://github.com/chevex/yargs.git\n\nTo run the tests with [expresso](http://github.com/visionmedia/expresso),\njust do:\n    \n    expresso\n\ninspired By\n===========\n\nThis module is loosely inspired by Perl's\n[Getopt::Casual](http://search.cpan.org/~photo/Getopt-Casual-0.13.1/Casual.pm).\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/chevex/yargs/issues"
  },
  "homepage": "https://github.com/chevex/yargs",
  "_id": "yargs@1.3.1",
  "_from": "yargs@^1.2.6"
}
