1 {
   2   "name": "posix-getopt",
   3   "version": "0.0.1",
   4   "description": "POSIX-style getopt()",
   5   "author": {
   6     "name": "Dave Pacheco",
   7     "url": "dap@cs.brown.edu"
   8   },
   9   "engines": {
  10     "node": "*"
  11   },
  12   "main": "./lib/getopt",
  13   "readme": "\nnode-getopt\n==============\n\nOverview\n--------\n\nnode-getopt is a Node.js module providing an interface to the POSIX-defined\ngetopt() function, a general-purpose command line parser that follows the POSIX\nguidelines for command-line utilities.  Using these guidelines encourages\ncommon conventions among applications, including use of:\n\n    o short option names (e.g., \"-r\")\n    o options with arguments (e.g., \"-f filename or -ffilename\")\n    o chaining short option names when options have no arguments (e.g., \"-ra\")\n\nThis implementation mirrors the Solaris getopt() implementation and supports\nlong option names (e.g., \"--recurse\"), potentially with values specified using\n\"=\" (e.g., \"--file=/path/to/file\").\n\nUnlike other option parsers available for Node.js, the POSIX getopt() interface\nsupports using the same option multiple times (e.g., \"-vvv\", commonly used to\nindicate level of verbosity).\n\nFor further reference on the relevant POSIX standards, see the following:\n\n    http://pubs.opengroup.org/onlinepubs/009695399/functions/getopt.html\n    http://pubs.opengroup.org/onlinepubs/009695399/utilities/getopts.html\n\nThe Utility Syntax Guidelines are described here:\n\n    http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html\n\n\nStatus\n------\n\nThis module is considered complete except that\n\n    o test coverage is pretty minimal\n    o npm install has not been tested\n    o the source is not javascriptlint-clean\n\nThere are no known bugs, but the module has not been extensively tested.\n\n\nPlatforms\n---------\n\nThis module should work on all platforms that support node.js.  The module is\ntested on MacOS X 10.6.5 and OpenSolaris based on build 111b and Illumos build\n147.\n\n\nInstallation\n------------\n\nAs an npm package, node-getopt is installed in the usual way:\n\n      % npm install posix-getopt\n\n\nAPI\n---\n\n### `new getopt.BasicParser(optstring, argv)`\n\nInstantiates a new object for parsing the specified arguments using the\nspecified option string.  This interface is closest to the traditional getopt()\nC function.  Callers first instantiate a BasicParser and then invoke the\ngetopt() method to iterate the options as they would in C.  (This interface\nallows the same option to be specified multiple times.)  The first two arguments\nin \"argv\" are ignored, since they generally denote the path to the node\nexecutable and the script being run, so options start with the third element.\n\nThe option string consists of an optional leading \":\" (see below) followed by a\nsequence of option-specifiers.  Each option-specifier consists of a single\ncharacter denoting the short option name, optionally followed by a colon if the\noption takes an argument and/or a sequence of strings in parentheses\nrepresenting long-option aliases for the option name.\n\nExample option strings:\n        ':r'            Command takes one option with no args: -r\n        ':ra'           Command takes two option with no args: -r and -a\n        ':raf:'         Command takes two option with no args: -r and -a\n                        and a single option that takes an arg: -f\n        ':f:(file)'     Command takes a single option with an argument: -f\n                        -f can also be specified as --file\n\nThe presence of a leading colon in the option string determines the behavior\nwhen an argument is not specified for an option which takes an argument.  See\ngetopt() below.  Additionally, if no colon is specified, then error messages are\nprinted to stderr when invalid options, options with missing arguments, or\noptions with unexpected arguments are encountered.\n\n\n### `parser.optind()`\n\nReturns the next argv-argument to be parsed.  When options are specified as\nseparate \"argv\" arguments, this value is incremented with each option parsed.\nWhen multiple options are specified in the same argv-argument, the returned\nvalue is unspecified.  This matches the variable \"OPTIND\" from the POSIX\nstandard, but is read-only.  (If you want to reset OPTIND, you must create a new\nBasicParser instance.)  This is most useful after parsing has finished to\nexamine the non-option arguments.\n\nThis value starts at \"2\" as described under \"Departures from POSIX\" below.\n\n\n### `parser.getopt()`\n\nReturns the next argument specified in \"argv\" (the object's constructor\nargument).  The returned value is either undefined or an object with at least\nthe following members:\n\n\toption\t\tsingle-character option name\n\nThe following members may also be present:\n\n\toptarg\t\targument value, if any\n\n\toptopt\t\toption character that caused the error, if any\n\n\terror\t\tif true, this object represents an error\n\nThis function scans \"argv\" starting at the current value of \"optind\" and returns\nan object describing the next argument based on the following cases:\n\n    o If the end of command line arguments is reached, an undefined value is\n      returned.  The end of arguments is signified by a single '-' argument, a\n      single '--' argument, an argument that's neither an option nor a previous\n      option's argument, the end of argv, or an error.\n\n    o If an unrecognized command line option is found (i.e. an option character\n      not defined in \"optstring\"), the returned object's \"option\" member\n      is just \"?\".  \"optopt\" is set to the unrecognized option letter.  \"error\"\n      is set to a true value.\n\n    o If a known command line option is found and the option takes no arguments\n      then the returned object's \"option\" member is the option's short name\n      (i.e.  the single character specifier in \"optstring\").\n      \n    o If a known command line option is found and that option takes an argument\n      and the argument is also found, then the returned object's \"option\"\n      member is the option's short name and the \"optarg\" member contains the\n      argument's value.\n\n    o If a known command line option is found and that option takes an argument\n      but the argument is not found, then the returned object's \"option\" member\n      is \"?\" unless the first character of \"optstring\" was a colon, in which\n      case the \"option\" member is set to \":\".  Either way, the \"optopt\" member\n      is set to the option character that caused the error and \"error\" is set to\n      a true value.\n\n\nDepartures from POSIX\n--------\n\n    o Global state in the C implementation (e.g., optind, optarg, and optopt) is\n      encapsulated in the BasicParser object.  optind is available as a method\n      call on the parser object.  optarg and optopt are returned directly by\n      getopt().\n\n    o Rather than returning an integer or character, getopt() returns an object\n      with the \"option\" field corresponding to the processed option character\n      and possibly the additional \"optarg\" and \"optopt\" fields.  If an error\n      occurs on a particular option, \"error\" is also set.  If an error occurs on\n      no particular option or if the end of input is encountered, undefined is\n      returned.\n\n    o Long option forms are supported as described above.  This introduces an\n      additional error case which is where an argument of the form\n      --option=value is encountered, where \"option\" does not take a value.\n\n    o POSIX starts \"optind\" at 1, since argv[0] is generally the name of the\n      command and options start at argv[1].  This implementation starts \"optind\"\n      at 2, since argv[0] is generally the path to the node binary and argv[1]\n      is the path to the script, so options start with argv[2].\n\n\nExamples\n--------\n\n### Example 1: simple short options\n\n\tvar mod_getopt = require('getopt')\n\tvar parser, option;\n\t\n\tparser = new mod_getopt.BasicParser('la',\n\t    ['node', 'script', '-l', '-a', 'stuff']);\n\twhile ((option = parser.getopt()) !== undefined && !option.error)\n\t\tconsole.error(option);\n\n### Example 2: invalid option specified\n\n\tvar mod_getopt = require('getopt')\n\tvar parser, option;\n\t\n\tparser = new mod_getopt.BasicParser('la',\n\t    ['node', 'script', '-l', '-b', 'stuff']);\n\twhile ((option = parser.getopt()) !== undefined && !option.error)\n\t\tconsole.error(option);\n\tconsole.error(option);\n\n### Example 3: long options\n\n\tvar mod_getopt = require('getopt')\n\tvar parser, option;\n\t\n\tparser = new mod_getopt.BasicParser('lar(recurse)',\n\t    ['node', 'script', '-l', '--recurse', 'stuff']);\n\twhile ((option = parser.getopt()) !== undefined && !option.error)\n\t\tconsole.error(option);\n\n### Example 4: options with arguments\n\n\tvar mod_getopt = require('getopt')\n\tvar parser, option;\n\t\n\tparser = new mod_getopt.BasicParser('f:lad:',\n\t    ['node', 'script', '-l', '-f', 'filename', '-dtype', 'stuff']);\n\twhile ((option = parser.getopt()) !== undefined && !option.error)\n\t\tconsole.error(option);\n\n### Example 5: options with missing arguments\n\n\tvar mod_getopt = require('getopt')\n\tvar parser, option;\n\t\n\tparser = new mod_getopt.BasicParser('f:la',\n\t    ['node', 'script', '-l', '-a', '-f']);\n\twhile ((option = parser.getopt()) !== undefined && !option.error)\n\t\tconsole.error(option);\n\tconsole.error(option);\n\n### Example 6: options specified multiple times\n\n\tvar mod_getopt = require('getopt')\n\tvar parser, option;\n\t\n\tparser = new mod_getopt.BasicParser('la',\n\t    ['node', 'script', '-l', '-a', '-l']);\n\twhile ((option = parser.getopt()) !== undefined && !option.error)\n\t\tconsole.error(option);\n",
  14   "readmeFilename": "README.md",
  15   "_id": "posix-getopt@0.0.1",
  16   "_from": "posix-getopt@~0.0.1"
  17 }