{"versions":{"0.5.0":{"author":{"name":"Andrey Tarantsov","email":"andreyvit@me.com"},"name":"dreamopt","description":"Command-line parser with readable syntax from your sweetest dreams","version":"0.5.0","homepage":"https://github.com/andreyvit/dreamopt.js","repository":{"type":"git","url":"git://github.com/andreyvit/dreamopt.js.git"},"main":"lib/dreamopt.js","scripts":{"test":"./node_modules/.bin/mocha"},"engines":{"node":">=0.4.0"},"dependencies":{},"devDependencies":{"mocha":">=0.3.1"},"_npmUser":{"name":"anonymous","email":"andreyvit@me.com"},"_id":"dreamopt@0.5.0","_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.5.5","_defaultsLoaded":true,"dist":{"shasum":"84d4a6e37e66e9f2c16bafc205ee7f5aa1e98319","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dreamopt/-/dreamopt-0.5.0.tgz"},"maintainers":[{"name":"anonymous","email":"andreyvit@me.com"}],"directories":{},"contributors":[]},"0.5.1":{"author":{"name":"Andrey Tarantsov","email":"andreyvit@me.com"},"name":"dreamopt","description":"Command-line parser with readable syntax from your sweetest dreams","version":"0.5.1","homepage":"https://github.com/andreyvit/dreamopt.js","repository":{"type":"git","url":"git://github.com/andreyvit/dreamopt.js.git"},"main":"lib/dreamopt.js","scripts":{"test":"./node_modules/.bin/mocha"},"engines":{"node":">=0.4.0"},"dependencies":{"wordwrap":">=0.0.2"},"devDependencies":{"mocha":">=0.3.1"},"_npmUser":{"name":"anonymous","email":"andreyvit@me.com"},"_id":"dreamopt@0.5.1","_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.5.5","_defaultsLoaded":true,"dist":{"shasum":"bb09993fbda43908e490f0b6596947f2568d6f12","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dreamopt/-/dreamopt-0.5.1.tgz"},"maintainers":[{"name":"anonymous","email":"andreyvit@me.com"}],"directories":{},"contributors":[]},"0.6.0":{"author":{"name":"Andrey Tarantsov","email":"andreyvit@me.com"},"name":"dreamopt","description":"Command-line parser with readable syntax from your sweetest dreams","version":"0.6.0","homepage":"https://github.com/andreyvit/dreamopt.js","repository":{"type":"git","url":"git://github.com/andreyvit/dreamopt.js.git"},"main":"lib/dreamopt.js","scripts":{"test":"./node_modules/.bin/mocha"},"engines":{"node":">=0.4.0"},"dependencies":{"wordwrap":">=0.0.2"},"devDependencies":{"mocha":">=0.3.1"},"_npmUser":{"name":"anonymous","email":"andreyvit@me.com"},"_id":"dreamopt@0.6.0","_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.5.5","_defaultsLoaded":true,"dist":{"shasum":"d813ccdac8d39d8ad526775514a13dda664d6b4b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dreamopt/-/dreamopt-0.6.0.tgz"},"maintainers":[{"name":"anonymous","email":"andreyvit@me.com"}],"directories":{},"contributors":[]},"0.7.0":{"author":{"name":"Andrey Tarantsov","email":"andreyvit@me.com"},"name":"dreamopt","description":"Command-line parser with readable syntax from your sweetest dreams","version":"0.7.0","homepage":"https://github.com/andreyvit/dreamopt.js","repository":{"type":"git","url":"git://github.com/andreyvit/dreamopt.js.git"},"main":"lib/dreamopt.js","scripts":{"test":"./node_modules/.bin/mocha"},"engines":{"node":">=0.4.0"},"dependencies":{"wordwrap":">=0.0.2"},"devDependencies":{"mocha":">=0.3.1"},"_npmUser":{"name":"anonymous","email":"andreyvit@me.com"},"_id":"dreamopt@0.7.0","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.16","_nodeVersion":"v0.6.15","_defaultsLoaded":true,"dist":{"shasum":"8248a73aab8a1d4190bb9e216615b31d7ce031f7","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dreamopt/-/dreamopt-0.7.0.tgz"},"maintainers":[{"name":"anonymous","email":"andreyvit@me.com"}],"directories":{},"contributors":[]},"0.8.0":{"author":{"name":"Andrey Tarantsov","email":"andreyvit@me.com"},"name":"dreamopt","description":"Command-line parser with readable syntax from your sweetest dreams","version":"0.8.0","homepage":"https://github.com/andreyvit/dreamopt.js","repository":{"type":"git","url":"git://github.com/andreyvit/dreamopt.js.git"},"main":"lib/dreamopt.js","scripts":{"test":"./node_modules/.bin/mocha"},"engines":{"node":">=0.4.0"},"dependencies":{"wordwrap":">=0.0.2"},"devDependencies":{"mocha":">=0.3.1"},"_npmUser":{"name":"anonymous","email":"andreyvit@me.com"},"_id":"dreamopt@0.8.0","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.16","_nodeVersion":"v0.6.15","_defaultsLoaded":true,"dist":{"shasum":"5bcc80be7097e45fc489c342405ab68140a8c1d9","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dreamopt/-/dreamopt-0.8.0.tgz"},"maintainers":[{"name":"anonymous","email":"andreyvit@me.com"}],"directories":{},"contributors":[]}},"dist-tags":{"latest":"0.8.0"},"name":"dreamopt","time":{"modified":"2022-01-26T20:43:46.783Z","created":"2022-01-26T20:43:46.783Z","0.5.0":"2011-12-28T14:37:09.514Z","0.5.1":"2011-12-29T14:07:32.601Z","0.6.0":"2012-04-04T11:23:21.301Z","0.7.0":"2012-05-25T08:24:25.179Z","0.8.0":"2012-07-28T09:33:10.247Z"},"readme":"Command-Line Parser With Readable Syntax From Your Sweetest Dreams\n==================================================================\n\nEver wrote crap code to deal with parsing command-line options? No more. Here's how it should look like (in CoffeeScript):\n\n    options = require('dreamopt') [\n      \"Usage: myscript [options] <source> [<destination>]\"\n\n      \"  <source>           Source file to compile into css #required\"\n      \"  <destination>      Destination file (defaults to source file with .css extension)\", (value, options) ->\n        if !value\n          return options.source.replace(/\\.mess/, '') + '.css'\n\n      \"Processing options:\"\n      \"  -n, --dry-run    Don't write anything to disk\"\n      \"  -m, --mode MODE  Set execution mode: easy, medium, hard (defaults to medium)\"\n\n      \"Connection options:\"\n      \"  -p, --port PORT  Port to connect to (default: 80)\"\n      \"  -h, --host HOST  Host to connect to (default is localhost)\"\n\n      \"Getting useful information:\"\n      \"  --reporters      Print a list of reporters and exit\", ->\n        console.log \"Reporters: foo, bar, boz\"\n        process.exit 0\n    ]\n\n    console.log JSON.stringify(options, null, 2)\n\nTry to run it as `node examples/foo.js`:\n\n    Error: Missing required argument #1: source\n\nNow run it as `node examples/foo.js myfile.mess`:\n\n    {\n      \"mode\": \"medium\",\n      \"port\": 80,\n      \"host\": \"localhost\",\n      \"source\": \"myfile.mess\",\n      \"destination\": \"myfile.css\",\n      \"argv\": [\n        \"myfile.mess\",\n        \"myfile.css\"\n      ]\n    }\n\n\nInstallation\n------------\n\n    npm install dreamopt\n\n\nFeatures\n--------\n\nOverview:\n\n* readable option specification with no extra punctuation\n* comprehensive test suite (221 tests so far)\n* returns a simple hash with predicable contents and coerced data types\n* mandatory and optional arguments/options\n* commands, subcommands, subsubcommands, with command-specific options and per-command help/usage\n* default values\n* optional callback functions\n* custom tags and coercion rules\n* automatic `--help`\n\nOption syntax details:\n\n* long options always start with double dashes (`--long`), short options with a single dash (`-s`)\n* a single dash by itself (`-`) is considered a positional argument rather than an option (and usually signifies reading from stdin)\n* `--` ends option processing\n* option value can be specified as `-sVAL`, `-s VAL`, `--long=VAL` or `--long VAL`\n* short options can be combined (`-xc`)\n* short option that requires a value consumes the remainder of the combined option if any (`-xcfMYFILE`, `-pi.tmp`)\n\n\nUsage\n-----\n\nThis module can called with up to three arguments:\n\n    options = require('dreamopt')(spec, [options])\n\nwhere:\n\n* `spec` is a required array of strings\n* `options` is an optional hash (i.e. a JavaScript object)\n\nThe following options can be specified:\n\n* `options.argv` is an array of command-line arguments, defaults to `process.argv.slice(2)`\n* `options.customTags` is a hash with custom tag handlers\n* `options.error(err)` is a function that handles syntax error, the default one prints `err.message` and exits\n* `options.help(usage)` is a function that handles `--help`, the default one prints `usage` and exits\n* `options.loadCommandSyntax(command)` is a function that returns the subcommand syntax for the given command\n\n\nSpecification format\n--------------------\n\nEach line of `spec` can be:\n\n* `Usage: blah blag` — a banner, it is displayed at the very top of the usage info\n* `Something:` — a header, it is displayed verbatim with appropriate spacing; if you don't define any headers, dreamopt will add the default ones as needed (“Arguments:” and “Options:”)\n* `-s, --long <value>  Description #tag1 #tag2(val2)` — option definition; must start with at least one space; if description or tags are specified, they must be separated from the option itself by at least two spaces; tags must be in the end and may have optional values\n* `-s, --long VALUE  Description #tag1 #tag2(val2)` — can use `VALUE` instead of `<value>`\n* `<arg>  Description #tag1 #tag2` — positional argument definition, same format as options\n* `ARG  Description #tag1 #tag2` — can use `ARG` instead of `<arg>`\n* after an option or an argument, you can include a function to be invoked when the option/argument is encountered\n* `command  Description` followed by a handler function (optional) and an array (required unless you provide `options.loadCommandSyntax`) — subcommand definition\n\nAny other lines that don't start with whitespace are output verbatim, as a paragraph of text. (Lines that start with whitespace must conform to option, argument or subcommand syntax.)\n\n\nCommands\n--------\n\nSyntax:\n\n    options = require('dreamopt') [\n      \"Commands:\"\n      \"  init             Create a new repository in the current folder\", []\n      \"  commit           Commit the staged changes\", []\n\n      \"Common options:\"\n      \"  -v, --verbose    Print tons of useless info\"\n    ]\n\n    switch options.command\n      when 'init'\n        ...\n      when 'commit'\n        ...\n\nYou can specify a function to run for each command:\n\n    doInit = (options) ->\n      ...\n\n    doCommit = (options) ->\n      ...\n\n    options = require('dreamopt') [\n      \"Commands:\"\n      \"  init             Create a new repository in the current folder\", [], doInit\n      \"  commit           Commit the staged changes\", [], doCommit\n    ]\n\nCommand-specific options and help:\n\n    INIT_SYNTAX = [\n      \"Create a new repository in the current folder.\"\n\n      \"  -b, --bare     Create a bare repository\"\n    ]\n\n    COMMIT_SYNTAX = [\n      \"Commit the staged changes.\"\n\n      \"Usage: git commit [options] [<file>...]\"\n\n      \"  -a, --all      Auto-add all changes\"\n      \"<file>           The file to commit #list\"\n    ]\n\n    options = require('dreamopt') [\n      \"Commands:\"\n      \"  init\", doInit, INIT_SYNTAX\n      \"  commit\", doCommit, COMMIT_SYNTAX\n\n      \"Common options:\"\n      \"  -v, --verbose    Print tons of useless info\"\n    ]\n\nModularizing your code:\n\n    # main.coffee:\n    options = require('dreamopt') [\n      \"Commands:\n      \"  init\"\n      \"  commit\"\n\n      \"Common options:\"\n      \"  -v, --verbose    Print tons of useless info\"\n    ], {\n      loadCommandSyntax: (command) -> require(\"./commands/#{command}\").usage\n    }\n\n    require(\"./commands/#{options.command}\").run(options)\n\n    # commands/commit.coffee:\n    exports.usage = [\n      \"Commit the staged changes.\"\n\n      \"Usage: git commit [options] [<file>...]\"\n\n      \"  -a, --all      Auto-add all changes\"\n      \"<file>           The file to commit #list\"\n    ]\n\n    exports.run = (options) ->\n      ...\n\nCommands can be nested, which results in `options.command`, `options.subcommand`, `options.subsubcommand` etc; loadCommandSyntax is called with a space-separated command name for nested commands.\n\n\nCoercion, validation and custom tags\n------------------------------------\n\nArgument values are automatically coerced to numbers if possible, otherwise they are provided as strings. You can specify one of the following tags to change coercion rules:\n\n* `#string` disables coercion and always returns a string\n* `#int` always coerces to int, giving an error if that's impossible\n\nYou can define custom tags to handle coercion, validation or any other processing. For example, to parse a simple YYYY-MM-DD date format, you can do:\n\n    options = require('../lib/dreamopt') [\n      \"-f, --from DATE  Only process records from the given date #date\"\n    ], {\n      date: (value, options, optionName) ->\n        if isNaN(new Date(value))\n          throw new Error(\"Invalid date for option #{optionName}\")\n        new Date(value)\n    }\n\n    console.log \"Year: \" + options.from?.getFullYear()\n\nTag functions are invoked with four arguments `(value, options, optionName, tagValue)`:\n\n* `value` is the value of the current option\n* `options` is the options hash built so far\n* `optionName` is useful when referring to the current option in an error message\n* `tagValue` is the value of the tag if any; for example, for `#date(today)` the tagValue would be `'today'`\n\n\nMagic tags\n----------\n\n* `#required` marks a required option or argument\n* `#var(fieldName)` overrides the options field for this option (i.e. the value is stored into `options.fieldName`)\n* `#default(value)` specifies a default value\n* `#list` marks an option that may be used multiple times; the final value is a JavaScript array\n* `#fancydefault` forces the callback function associated with the current option to be called even when an argument is not provided and no default is set; in this case, the original value will be `null` and your function is expected to return a better one\n* `#delayfunc` delays invocation of the callback function until all other options and arguments are processed; this is useful for options like `--help` or `--print-reporters`, when you want all normal options to be handled and validated before the callback is invoked; the return value of such callback functions is ignored\n\nAdditionally, you may encounter the following internal tags in the source code:\n\n* `#flag` denotes a no-values option (which is always treated as boolean)\n* `#acceptsno` is set for options which use `--[no-]something` in their definition; all boolean option accept --no-option variant to turn them off, but only options explicitly specified as such are documented as accepting --no variants in usage info\n\n\nAutomatic usage info\n--------------------\n\nIf you don't define a `--help` option, it is provided for you automatically and prints a usage info like this:\n\n    Usage: myscript [options] <source.mess> [<destination.css>]\n\n    Arguments:\n      <source>              Source file to compile into css\n      <destination>         Destination file (defaults to source file with .css extension)\n\n    Processing options:\n      -n, --dry-run         Don't write anything to disk\n      -m, --mode MODE       Set execution mode: easy, medium, hard (defaults to medium)\n\n    Connection options:\n      -p, --port PORT       Port to connect to (default: 80)\n      -h, --host HOST       Host to connect to (default is localhost)\n\n    Getting useful information:\n          --reporters       Print a list of reporters and exit\n      -h, --help            Display this usage information\n\nYou can provide `options.help(usageText)` function to customize the way this usage info is printed; the default implementation outputs the argument via `process.stdout.write` and executes `process.exit(0)`.","users":{}}