{"_id":"options-parser","_rev":"13-48317d6f3ccd480812fbdb0c25cd9282","name":"options-parser","description":"A full-featured no-nonsense command line parser with no external dependencies","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"options-parser","version":"0.1.0","description":"A full-featured no-nonsense command line parser with no external dependencies","keywords":["getopt","arguments"],"license":"BSD-3-Clause","author":{"name":"Janus Tøndering","email":"janus@toendering.dk"},"main":"parser.js","devDependencies":{"mocha":"1.17.*","should":"3.1.*"},"scripts":{"test":"mocha"},"_id":"options-parser@0.1.0","dist":{"shasum":"aa6172fc63764b912ba9eba6543073c55846d8ac","tarball":"https://registry.npmjs.org/options-parser/-/options-parser-0.1.0.tgz","integrity":"sha512-9gttP9PmXILHRtobLu8++jZAVWWSttIxP+0946RvDRckm6ADk1zdpriotKDSn4iKqAJRLthEcaF86wKJeVtKjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICvpF0YvbbPbrHXsba7ssExK1dvn01gFeLwHhcANCE8iAiEA+XrM545WbVJAOh34ohIcGE0QEsc120M+uxUDEvcgvWs="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"janusnt","email":"janus@toendering.dk"},"maintainers":[{"name":"janusnt","email":"janus@toendering.dk"}]},"0.1.1":{"name":"options-parser","version":"0.1.1","description":"A full-featured no-nonsense command line parser with no external dependencies","keywords":["getopt","arguments"],"license":"BSD-3-Clause","author":{"name":"Janus Tøndering","email":"janus@toendering.dk"},"main":"parser.js","repository":{"type":"git","url":"http://github.com/janus-toendering/options-parser.git"},"devDependencies":{"mocha":"1.17.*","should":"3.1.*"},"scripts":{"test":"mocha"},"bugs":{"url":"https://github.com/janus-toendering/options-parser/issues"},"homepage":"https://github.com/janus-toendering/options-parser","_id":"options-parser@0.1.1","dist":{"shasum":"1e6df710cb5cbd8be350d03d3767e9f141e49498","tarball":"https://registry.npmjs.org/options-parser/-/options-parser-0.1.1.tgz","integrity":"sha512-ogjdALSwAVvh8l0xH09Xivcj4aCxW0ZJVU45B4cPumF9pPffDCm5A7MJtLTeyUsswuaD+k0LKPt/BZNCPjh4EA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDnhcJrRUIaPMpAa+Zsa0i5gtcoWR7huqHfidH8KzQjbgIgOhTPovs17wd00baa1Vl4YFhER5V8s8tUYdGKxG9QNJM="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"janusnt","email":"janus@toendering.dk"},"maintainers":[{"name":"janusnt","email":"janus@toendering.dk"}]},"0.2.0":{"name":"options-parser","version":"0.2.0","description":"A full-featured no-nonsense command line parser with no external dependencies","keywords":["getopt","arguments"],"license":"BSD-3-Clause","author":{"name":"Janus Tøndering","email":"janus@toendering.dk"},"main":"parser.js","repository":{"type":"git","url":"http://github.com/janus-toendering/options-parser.git"},"devDependencies":{"mocha":"1.17.*","should":"3.1.*"},"scripts":{"test":"mocha"},"bugs":{"url":"https://github.com/janus-toendering/options-parser/issues"},"homepage":"https://github.com/janus-toendering/options-parser","_id":"options-parser@0.2.0","dist":{"shasum":"83be8ae76f2e3f4f66c515b742f7de9cc8a3765b","tarball":"https://registry.npmjs.org/options-parser/-/options-parser-0.2.0.tgz","integrity":"sha512-fzlUAC6ZytuenaYcvL33YxD5BgcpBXaCmr7R0GDm8s+MLbwEaO6nzkBdwemmX3eg5Bz5DkhvcQ08wDD02EKJGA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDW323zkdxeMtf4P9rOddkw0t0Tn1hNi4QZXKu8Wb58aAiB2FCD5s5Z1TlfBsvkixMb9Xf426JEU405uGbzgD14hHQ=="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"janusnt","email":"janus@toendering.dk"},"maintainers":[{"name":"janusnt","email":"janus@toendering.dk"}]},"0.3.0":{"name":"options-parser","version":"0.3.0","description":"A full-featured no-nonsense command line parser with no external dependencies","keywords":["getopt","arguments"],"license":"BSD-3-Clause","author":{"name":"Janus Tøndering","email":"janus@toendering.dk"},"main":"parser.js","repository":{"type":"git","url":"http://github.com/janus-toendering/options-parser.git"},"devDependencies":{"mocha":"1.17.*","should":"3.1.*","istanbul":"0.2.*"},"scripts":{"test":"mocha","coverage":"istanbul cover _mocha -- -R spec"},"bugs":{"url":"https://github.com/janus-toendering/options-parser/issues"},"homepage":"https://github.com/janus-toendering/options-parser","_id":"options-parser@0.3.0","dist":{"shasum":"d393f50687495b68fdeb8a29677068de6f4af338","tarball":"https://registry.npmjs.org/options-parser/-/options-parser-0.3.0.tgz","integrity":"sha512-ZmT0ymtuAgWC8EY8mBm1Qlz+yf81xlNv63Oiq7r8gkvMZlhD0oDztCf6VYeHQlwJT4YTMycN7DvZz1m9wI30pw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDN4eA9+NmN7RQSnWUnX2iHR0/+yyC8Zv8XnW1lYEVbkQIhAIKkv5vPRp/P3qNhLp6KOURFws33PziDx/AoCv8NGCuu"}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"janusnt","email":"janus@toendering.dk"},"maintainers":[{"name":"janusnt","email":"janus@toendering.dk"}]},"0.4.0":{"name":"options-parser","version":"0.4.0","description":"A full-featured no-nonsense command line parser with no external dependencies","keywords":["getopt","arguments","options","command-line","option parser"],"license":"BSD-3-Clause","author":{"name":"Janus Tøndering","email":"janus@toendering.dk"},"main":"options-parser.js","repository":{"type":"git","url":"http://github.com/janus-toendering/options-parser.git"},"devDependencies":{"mocha":"1.17.*","should":"3.1.*","istanbul":"0.2.*"},"scripts":{"test":"mocha","coverage":"istanbul cover _mocha -- -R spec"},"bugs":{"url":"https://github.com/janus-toendering/options-parser/issues"},"homepage":"https://github.com/janus-toendering/options-parser","_id":"options-parser@0.4.0","dist":{"shasum":"9ca1e7996a62399f40e63d7fb7932f1412f10b95","tarball":"https://registry.npmjs.org/options-parser/-/options-parser-0.4.0.tgz","integrity":"sha512-KZTzRU3jlv9DVWakQGacYJN3GBP6KY6bb5Gh+QWy88ayADNCj5ql8a4604jBnorQ/bsVja4zjy8q0W8v+71gyg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBA4FEkNa62LM3djiHWyuP+ljT/3G2IVZ4SWcDXFyjTKAiEA8sxoaWt97llShy0qmZZJep+CcaRQfj6U5zF4oNNxuTA="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"janusnt","email":"janus@toendering.dk"},"maintainers":[{"name":"janusnt","email":"janus@toendering.dk"}]}},"readme":"options-parser\n==============\n\nA full-featured no-nonsense command line parser for node with no external dependencies\n\n# Installation\n```sh\n$ npm install --save options-parser\n```\n\n# Example\n```javascript\n\nvar options = require('options-parser');\n\nvar result = options.parse({\n  user:  { required: true },\n  all:   { short: 'a', flag: true },\n  host:  { short: 'h', default: 'localhost' },\n  input: { short: 'i', multi: true },\n  r:     { flag: true },\n  db:    { default: 'test' },\n  out:   { short: 'o', type: options.type.file.open.write() }\n});\n\nconsole.log(result);\n```\nRunning the above code with\n```sh\nnode example.js --user=joe -a --host www.example.com output.txt -i file1.txt --input file2.txt -o out.txt\n```\nwould produce\n```javascript\n{ opt: \n   { user: 'joe',\n     all: true,\n     host: 'www.example.com',\n     db: 'test',\n     input: [ 'file1.txt', 'file2.txt' ],\n     out: { name: 'out.txt', fd: 9 } },\n  args: [ 'output.txt' ] }\n```\n\n# Reference\n\n```javascript\noptions.parse(opts);\noptions.parse(opts, argv);\noptions.parse(opts, error);\noptions.parse(opts, argv, error);\n```\n\nThe first argument to .parse(...) is always the options object defining what to look for. Every key in the options object denotes the name of the option. The value is another object that can contain one of the following options\n\n```javascript\n{ \n  short: [char],            // short alias for this option (must have length = 1),\n  \n  required: [bool],         // if set to true, this option is required (default: false)\n  \n  flag: [bool],             // if true, this option takes no values. If false, this \n                            // option expects a value (ie. --host www.example.com)\n                            // (default: false)\n  \n  default: [string],        // default value of option if it is not present. \n                            // does not make sense to use with flag or required\n  \n  multi: [bool]             // If true, this option can be specified multiple times\n                            // and the resulting value will be an array (default: false)\n                            // If false, later options take precedence over earlier options\n  \n  help: [string],           // help text used when outputting help screen (see below),\n  \n  showHelp: [bool|object],  // automatically show help screen when this option is present \n                            // (implies flag: true if unset)\n  \n  varName: [string],        // name to use for value placeholder in help screen (see below)\n\n  type: [Function}          // Type validation. See more details below.\n}\n```  \n\nYou can pass an argv array as the second argument (optional). It should not contain the interpreter (node)\nand script name. This value defaults to process.argv.slice(2).\n\nIt is also possible to pass a string that will then be converted to the \ncorresponding argv array before it will be processed. This can be useful for\nreading command line parameters from a file.\n\nThe error parameter is a callback to use when errors are encountered. If nothing is provided, the default error handling will throw an exception.\n\n## Help screen\n\noptions-parser can automatically generate a suitable help screen for displaying\nthe available options and help text for the user.\n\n```javascript\noptions.help(opts, options);\n```\n\nopts is the same object you would pass to options.parse(...). options is an optional object literal with the following structure \n\n```javascript\n{\n  columns: [number],          // format text to fit the specified number of columns\n                              // if columns is not specified, it defaults to the current\n                              // screen with\n  \n  output: [function],         // use [function] instead of util.puts for output \n                              // (must have same signature)\n  \n  skipEmpty: [bool],          // leave out options that do not have a help text\n  \n  paddingLeft: [number],      // left padding of output (default: 2)\n  \n  separator: [string],        // separator string to use between option names \n                              // and help text (default: '   ')\n  \n  banner: [string],           // specify a banner to display as the first line of help output\n  \n  // the following are only available when passed to showHelp property of an opts object\n  \n  noExit: [bool],             // do not exit after displaying help screen invoked from \n                              // a showHelp option (default: false)\n                              \n  callback: [function]        // funciton to be called after help screen has been displayed\n  \n}\n```\n\nYou can pass a options object literal to the showHelp property in the opts object literal. This will be passed directly to the .help(...) method when the options is encountered.\n\n# Example 2\n\n```javascript\n// help-example.js\nvar options = require('options-parser');\noptions.parse({\n  file: {\n    short: 'f',\n    varName: 'FILE',\n    help: 'file to process'\n  },\n  q: {\n    help: 'do not print any output',\n    flag: true\n  },\n  help: {\n    short: 'h',\n    help: 'this help screen',\n    showHelp: { \n      banner: 'options-parser example: [options]'\n    }\n  }\n});\n```\n```bash\n$ node help-example.js --help\noptions-parser example: [options]\n  --file FILE, -f FILE   file to process\n  -q                     do not print any output\n  --help, -h             this help screen\n```\n\n## Type Validation\n\nTo ease validation of argument values you can pass a function\nto the \"type\" member of the options configuration object. The\nfunction takes two arguments: the value to validate and a \nreplacement function that takes one argument. If the validation\nsucceeds return true, otherwise return an error message string.\n\nThe replacement function can be used to replace the value being\nvalidated with a new value. Say you want to see if the value\nis a valid date. You can then use the replacement function to\nreplace the string value of the input with a Date object \nrepresenting the parsed date.\n\nThere are a few built-in type validation functions:\n```javascript\nvar options = require('options-parser');\n\n// require parameter value to be an integer\noptions.type.int(errorMessage);\n\n// require parameter value to be a valid file and open it for reading and writing\noptions.type.file.open(errorMessage, options);\n\n// require parameter value to be a valid file and open it for reading\noptions.type.file.open.read(errorMessage, options);\n\n// require parameter value to be a valid file and open it for writing\noptions.type.file.open.write(errorMessage, options);\n```\n\nThe errorMessage string is optional. If no error message is passed a default\nerror message will be used.\n\nThe options object can have two fields: `flags` and `mode` which reflect\nthe `flags` and `mode` parameters of the \n[fs.open api] (http://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback)\nfunction.\n\nThe `file.open.xxx` functions all replace the value with an object with two\nfields: `name` and `fd`. `name` is the name of the file as specified by the user and\n`fd` is the file descriptor of the opened file. See the first example near the top of the page\n","maintainers":[{"name":"janusnt","email":"janus@toendering.dk"}],"time":{"modified":"2022-06-23T01:22:33.552Z","created":"2014-02-16T20:15:02.266Z","0.1.0":"2014-02-16T20:15:02.266Z","0.1.1":"2014-02-17T22:16:38.027Z","0.2.0":"2014-02-21T09:36:12.969Z","0.3.0":"2014-07-14T10:03:53.235Z","0.4.0":"2014-08-15T11:30:12.869Z"},"readmeFilename":"README.md","homepage":"https://github.com/janus-toendering/options-parser","keywords":["getopt","arguments","options","command-line","option parser"],"repository":{"type":"git","url":"http://github.com/janus-toendering/options-parser.git"},"author":{"name":"Janus Tøndering","email":"janus@toendering.dk"},"bugs":{"url":"https://github.com/janus-toendering/options-parser/issues"},"license":"BSD-3-Clause","users":{"jefrancomix":true}}