{
  "author": {
    "name": "mklabs"
  },
  "name": "noptify",
  "description": "nopt wrapper with commander-like API",
  "version": "0.0.3",
  "repository": {
    "type": "git",
    "url": "git://github.com/mklabs/noptify.git"
  },
  "dependencies": {
    "nopt": "~2.0.0"
  },
  "devDependencies": {
    "mocha": "~1.8.1"
  },
  "scripts": {
    "test": "mocha --reporter spec"
  },
  "readme": "### noptify\n\nnoptify is a little wrapper around `nopt` module adding a more expressive,\ncommander-like, API and few helpers.\n\nExamples\n\n     var program = noptify(process.argv, { program: 'name' })\n       .version('0.0.1')\n       .option('port', '-p', 'Port to listen on (default: 35729)', Number)\n       .option('pid', 'Path to the generated PID file', String)\n\n     var opts = program.parse();\n\nReturns an instance of `Noptify`\n\n### Noptify\n\nNoptify provides the API to parse out option, shorthands and generate the\nproper generic help output.\n\n- args     - The Array of arguments to parse (default: `process.argv`);\n- options  - An hash of options with the following properties\n  - program - The program name to use in usage output\n\nEvery noptify instance is created with two options, `-h, --help` and `-v,\n--version`.\n\n### Noptify#parse\n\nParse the provided options and shorthands, pass them through `nopt` and\nreturn the result.\n\nWhen `opts.help` is set, the help output is displayed and `help`\nevent is emitted. The process exists with `0` status, the help output is\nautomatically displayed and the `help` event is emitted.\n\nExamples\n\n    var program = noptify(['foo', '--help'])\n      .on('help', function() {\n        console.log('Examples');\n        console.log('');\n        console.log('  foo bar --baz > foo.txt');\n      });\n\n    var opts = program.parse();\n    // ... Help output ...\n    // ... Custom help output ...\n    // ... Exit ...\n\n\n\n### Noptify#version\n\nDefine the program version.\n\n### Noptify#option\n\nDefine `name` option with optional shorthands, optional description and optional type.\n\n### Noptify#help\n\nSimply output to stdout the Usage and Help output.\n\n---\n\n*Mocha generated documentation*\n\n- [API](#api)\n- [Collectable](#collectable)\n- [Commandable](#commandable)\n  - [Parses remaining arguments and route to the appropriate command](#commandable-parses-remaining-arguments-and-route-to-the-appropriate-command)\n\n<a name=\"\"></a>\n\n<a name=\"api\"></a>\n## API\nreturns an instanceof Noptify.\n\n```js\nassert.ok(noptify() instanceof noptify.Noptify);\n```\n\nis typically used like so.\n\n```js\nvar program = noptify(['node', 'file.js', '-d', '--dirname', './', '-p', '3000', 'app.js', 'base.js'])\n  .option('debug', '-d', 'Enabled debug output', Boolean)\n  .option('dirname', 'The path to the output directory')\n  .option('port', '-p', 'The port you wish to listen on', Number)\n\n// opts => nopt result\nvar opts = program.parse();\n\nassert.deepEqual(opts, {\n  port: 3000,\n  debug: true,\n  dirname: './',\n  argv: {\n    remain: ['app.js', 'base.js'],\n    cooked: ['--debug', '--dirname', './', '--port', '3000', 'app.js', 'base.js'],\n    original: ['-d', '--dirname', './', '-p', '3000', 'app.js', 'base.js']\n  }\n});\n```\n\nallows definitiion of shorthands separately.\n\n```js\nvar opts = noptify(['node', 'file.js', '-lc'])\n  .option('line-comment', 'Ouputs with debugging information', Boolean)\n  .shorthand('lc', '--line-comment')\n  .parse();\n\nassert.equal(opts['line-comment'], true);\n```\n\n<a name=\"collectable\"></a>\n## Collectable\nprovides the helper method to read from stdin.\n\n```js\nvar program = noptify();\nassert.ok(typeof program.stdin === 'function', 'stdin defined');\n```\n\nis invoked only when .parse() is called.\n\n```js\nvar program = noptify(['', '']);\nvar str = 'testing out stdin helper';\nprogram.stdin(function(err, res) {\n  assert.equal(res, str);\n  done();\n});\n\nprogram.parse();\n\nprocess.nextTick(function() {\n  process.stdin.emit('data', str);\n  process.stdin.emit('end');\n});\n```\n\n<a name=\"commandable\"></a>\n## Commandable\nprovides the .command() utility.\n\n```js\nassert.ok(typeof noptify().command === 'function');\n```\n\n<a name=\"commandable-parses-remaining-arguments-and-route-to-the-appropriate-command\"></a>\n## Parses remaining arguments and route to the appropriate command\ncan be a simple function.\n\n```js\nvar program = noptify(['', '', 'init', '--debug', 'foo']).option('debug', 'an option');\n\nprogram.command('init', function(args, opts) {\n  // args ==> sliced args at command position\n  // opts ==> nopt parsed object\n  assert.deepEqual(args, ['--debug', 'foo']);\n  assert.equal(opts.debug, true);\n  assert.equal(opts.argv.remain[0], 'foo');\n  done();\n});\n\nprogram.parse();\n```\n\nor another program, an Noptify instance.\n\n```js\nvar args = ['', '', 'init', '--debug', 'myapp', 'foo'];\n\nvar init = noptify(args)\n  .option('debug', 'Debug output')\n  .command('myapp', done.bind(null, null));\n\nnoptify(args).command('init', init).parse();\n```\n\n",
  "readmeFilename": "readme.md",
  "_id": "noptify@0.0.3",
  "_from": "noptify@latest"
}
