{
  "name": "nomnom",
  "description": "Option parser with generated usage and commands",
  "version": "1.6.1",
  "author": {
    "name": "Heather Arthur",
    "email": "fayearthur@gmail.com"
  },
  "scripts": {
    "test": "./node_modules/.bin/nodeunit test/*.js"
  },
  "repository": {
    "type": "git",
    "url": "http://github.com/harthur/nomnom.git"
  },
  "main": "./nomnom",
  "keywords": [
    "arguments",
    "option parser",
    "command line",
    "options",
    "parser"
  ],
  "dependencies": {
    "colors": "0.5.x",
    "underscore": "~1.4.4"
  },
  "devDependencies": {
    "nodeunit": "~0.7.4"
  },
  "readme": "# nomnom\nnomnom is an option parser for node. It noms your args and gives them back to you in a hash.\n\n```javascript\nvar opts = require(\"nomnom\")\n   .option('debug', {\n      abbr: 'd',\n      flag: true,\n      help: 'Print debugging info'\n   })\n   .option('config', {\n      abbr: 'c',\n      default: 'config.json',\n      help: 'JSON file with tests to run'\n   })\n   .option('version', {\n      flag: true,\n      help: 'print version and exit',\n      callback: function() {\n         return \"version 1.2.4\";\n      }\n   })\n   .parse();\n\nif (opts.debug)\n   // do stuff\n```\n\nYou don't have to specify anything if you don't want to:\n\n```javascript\nvar opts = require(\"nomnom\").parse();\n\nvar url = opts[0];     // get the first positional arg\nvar file = opts.file   // see if --file was specified\nvar verbose = opts.v   // see if -v was specified\nvar extras = opts._    // get an array of the unmatched, positional args\n```\n\n# Install\nfor [node.js](http://nodejs.org/) and [npm](http://github.com/isaacs/npm):\n\n\tnpm install nomnom\n\n# More Details\nNomnom supports args like `-d`, `--debug`, `--no-debug`, `--file=test.txt`, `--file test.txt`, `-f test.txt`, `-xvf`, and positionals. Positionals are arguments that don't fit the `-a` or `--atomic` format and aren't attached to an option.\n\nValues are JSON parsed, so `--debug=true --count=3 --file=log.txt` would give you:\n\n```\n{\n   \"debug\": true,\n   \"count\": 3,\n   \"file\": \"log.txt\"\n}\n```\n\n# Commands\nNomnom supports command-based interfaces (e.g. with git: `git add -p` and `git rebase -i` where `add` and `rebase` are the commands):\n\n```javascript\nvar parser = require(\"nomnom\");\n\nparser.command('browser')\n   .callback(function(opts) {\n      runBrowser(opts.url);\n   })\n   .help(\"run browser tests\");\n\nparser.command('sanity')\n   .option('outfile', {\n      abbr: 'o',\n      help: \"file to write results to\"\n   })\n   .option('config', {\n      abbr: 'c',\n      default: 'config.json',\n      help: \"json manifest of tests to run\"\n   })\n   .callback(function(opts) {\n      runSanity(opts.filename);\n   })\n   .help(\"run the sanity tests\")\n\nparser.parse();\n```\n\nEach command generates its own usage message when `-h` or `--help` is specified with the command.\n\n# Usage\nNomnom prints out a usage message if `--help` or `-h` is an argument. Usage for these options in `test.js`:\n\n```javascript\nvar opts = require(\"nomnom\")\n   .script(\"runtests\")\n   .options({\n      path: {\n         position: 0,\n         help: \"Test file to run\",\n         list: true\n      },\n      config: {\n         abbr: 'c',\n         metavar: 'FILE',\n         help: \"Config file with tests to run\"\n      },\n      debug: {\n         abbr: 'd',\n         flag: true,\n         help: \"Print debugging info\"\n      }\n   }).parse();\n```\n\n...would look like this:\n\n\tusage: runtests <path>... [options]\n\n\tpath     Test file to run\n\n\toptions:\n\t   -c FILE, --config FILE   Config file with tests to run\n\t   -d, --debug              Print debugging info\n\n# Options\nYou can either add a specification for an option with `nomnom.option('name', spec)` or pass the specifications to `nomnom.options()` as a hash keyed on option name. Each option specification can have the following fields:\n\n#### abbr and full\n`abbr` is the single character string to match to this option, `full` is the full-length string (defaults to the name of the option).\n\nThis option matches `-d` and `--debug` on the command line:\n\n```javascript\nnomnom.option('debug', {\n   abbr: 'd'\n})\n```\n\nThis option matches `-n 3`, `--num-lines 12` on the command line:\n\n```javascript\nnomnom.option('numLines', {\n   abbr: 'n',\n   full: 'num-lines'\n})\n```\n\n#### flag\n\nIf this is set to true, the option acts as a flag and doesn't swallow the next value on the command line. Default is `false`, so normally if you had a command line `--config test.js`, `config` would get a value of `test.js` in the options hash. Whereas if you specify:\n\n```javascript\nnomnom.option('config', {\n   flag: true\n})\n```\n\n`config` would get a value of `true` in the options hash, and `test.js` would be a free positional arg.\n\n#### metavar\n\n`metavar` is used in the usage printout e.g. `\"PATH\"` in `\"-f PATH, --file PATH\"`.\n\n#### string\n\nA shorthand for `abbr`, `full`, and `metavar`. For example, to attach an option to `-c` and `--config` use a `string: \"-c FILE, --config=FILE\"`\n\n#### help\n\nA string description of the option for the usage printout.\n\n#### default\n\nThe value to give the option if it's not specified in the arguments.\n\n#### callback\n\nA callback that will be executed as soon as the option is encountered. If the callback returns a string it will print the string and exit:\n\n```javascript\nnomnom.option('count', {\n   callback: function(count) {\n      if (count != parseInt(count))\n         return \"count must be an integer\";\n   }\n})\n```\n\n#### position\n\nThe position of the option if it's a positional argument. If the option should be matched to the first positional arg use position `0`, etc.\n\n#### list\n\nSpecifies that the option is a list. Appending can be achieved by specifying the arg more than once on the command line:\n\n\tnode test.js --file=test1.js --file=test2.js\n\nIf the option has a `position` and `list` is `true`, all positional args including and after `position` will be appended to the array.\n\n#### required\n\nIf this is set to `true` and the option isn't in the args, a message will be printed and the program will exit.\n\n#### choices\n\nA list of the possible values for the option (e.g. `['run', 'test', 'open']`). If the parsed value isn't in the list a message will be printed and the program will exit.\n\n#### type\n\nIf you don't want the option JSON-parsed, specify type `\"string\"`.\n\n#### hidden\n\nOption won't be printed in the usage\n\n\n# Parser interface\n`require(\"nomnom\")` will give you the option parser. You can also make an instance of a parser with `require(\"nomnom\")()`. You can chain any of these functions off of a parser:\n\n#### option\n\nAdd an option specification with the given name:\n\n```javascript\nnomnom.option('debug', {\n   abbr: 'd',\n   flag: true,\n   help: \"Print debugging info\"\n})\n```\n\n#### options\n\nAdd options as a hash keyed by option name, good for a cli with tons of options like [this example](http://github.com/harthur/replace/blob/master/bin/replace.js):\n\n```javascript\nnomnom.options({\n   debug: {\n      abbr: 'd',\n      flag: true,\n      help: \"Print debugging info\"\n   },\n   fruit: {\n      help: \"Fruit to buy\"\n   }\n})\n```\n\n#### usage\n\nThe string that will override the default generated usage message.\n\n#### help\n\nA string that is appended to the usage.\n\n#### script\n\nNomnom can't detect the alias used to run your script. You can use `script` to provide the correct name for the usage printout instead of e.g. `node test.js`.\n\n#### printer\n\nOverrides the usage printing function.\n\n#### command\n\nTakes a command name and gives you a command object on which you can chain command options.\n\n#### nocommand\n\nGives a command object that will be used when no command is called.\n\n#### parse\n\nParses node's `process.argv` and returns the parsed options hash. You can also provide argv:\n\n```javascript\nvar opts = nomnom.parse([\"-xvf\", \"--atomic=true\"])\n```\n\n#### nom\n\nThe same as `parse()`.\n\n# Command interface\nA command is specified with `nomnom.command('name')`. All these functions can be chained on a command:\n\n#### option\n\nAdd an option specifically for this command.\n\n#### options\n\nAdd options for this command as a hash of options keyed by name.\n\n#### callback\n\nA callback that will be called with the parsed options when the command is used.\n\n#### help\n\nA help string describing the function of this command.\n\n#### usage\n\nOverride the default generated usage string for this command.\n",
  "readmeFilename": "README.md",
  "_id": "nomnom@1.6.1",
  "_from": "nomnom@1.6.x"
}
