summaryrefslogtreecommitdiff
path: root/deps/npm/test/npm_cache/_cacache/content-v2/sha512/79/ec/4625bec1a13aaefdcd4e7cf18f1c5575879d80e8bdba063cc962c959c48526a0c1c9e3766c95ec9ea1cf10cd954968f3bfec136f0d3aa87009db05cf4666
blob: 2e95263ba3890bb9d0f12c37caada80628b0ac9b (plain)
1
{"_id":"clean","_rev":"33-7bb9012e61b414bbf93c168b5e95108c","name":"clean","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","dist-tags":{"latest":"2.1.6"},"versions":{"0.0.0":{"name":"clean","version":"0.0.0","description":"","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":"","license":"MIT","readme":"ERROR: No README data found!","_id":"clean@0.0.0","dist":{"shasum":"86cb7c9efff672cd768b54039c133057f4b810f2","tarball":"http://localhost:1337/clean/-/clean-0.0.0.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"1.1.4":{"name":"clean","version":"1.1.4","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n\n# Argv-parser\n\n> Argv-parser is a small and simple node.js module to parse `process.argv`\n\nArgv-parser is designed to be simple and will do nothing about:\n\n- option registration\n- description of options\n- output\n\n## Installation\n\n```sh\nnpm install argv-parser --save\n```\n\n## Usage\n\n```js\nvar parser = require('argv-parser');\n```\n\n## parser.parse(argv, options)\n\nParse argument vector (argv) or something like argv.\n\n##### Returns `ret` `Object`\n\n- parsed: `Object` the parsed object\n- warnings: `Object` the warnings of each option. If not exists, `ret.warning` will be an empty object\n- errors: `Object` the errors of each option.\n\n##### argv `Array`\n\n`process.argv` or something like that.\n\n##### options `Object`\n\n- rules: `Object` an extended `nopt` rules\n- offset: `Number` (optional, default to `2`) the offset from which the parser should start to parse.\n\n\n## parser.clean(data, options)\n\n##### Returns\n\nThe same as `parser.parse`\n\n##### options `Object`\n\n- rules: `Object`\n- types: `Object` (optional) type definitions. For most cases, you needn't this option\n\n\n## options.rules\n\n\n## Example\n\ntest.js\n\n```js\nvar rules = {\n    open: {\n        type: Boolean,\n        value: true\n    },\n\n    port: {\n        type: Number,\n        short: 'p',\n        value: function(port, parsed, tool) {\n            if(!port){\n                port = 9230;\n            }\n\n            if(port < 8000){\n                tool.warn('port < 8000 which is dangerous');\n                \n                if(port < 1000){\n                \ttool.error('port < 100 which is forbidden');\n        \t\t\treturn;\n                }\n            }\n\n            return port;\n        }\n    },\n\n    html: {\n        type: 'html',\n    },\n\n    name: {\n        type: String\n    }\n};\n\nvar data = parser.parse(process.argv, {\n\trules: rules\n});\n```\n\nDefault values:\n\n```\n$ node test.js\n> data.parsed.open; // true\n> data.parsed.port; // 9230\n\n```\n\nType limitation:\n\n```\n$ node test.js --port 8888 --no-open --name name<script>alert(123)</script>\n> data.parsed.open; // false\n> data.parsed.port; // 8888\n> data.parsed.name; // 'namealert(123)'; -> stripped\n> data.errors;      // {}\n> data.warnings;    // {}\n```\n\nWarnings and errors:\n\n```\n$ node test.js --port 888 --no-open --name name<script>alert(123)</script>\n> data.parsed.open; // false\n> data.parsed.port; // undefined; -> error\n> data.parsed.name; // 'name<script>alert(123)</script>'\n> data.errors;      // {port: ['port < 100 which is forbidden']}\n> data.warnings;    // {port: ['port < 8000 which is dangerous']}\n```\n\n\n\n\n\n\n","_id":"clean@1.1.4","dist":{"shasum":"5fe3f1d48a22842316eba0a19c51f26428015c80","tarball":"http://localhost:1337/clean/-/clean-1.1.4.tgz"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"2.1.1":{"name":"clean","version":"2.1.1","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n\n# clean\n\nClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\n\n- fully extendable types\n- shorthands\n- validatiors\n- setters\n\n# Installation and Usage\n\n```sh\nnpm install clean --save\n```\n\n```js\nvar clean = require('clean')(options);\n```\n\n# Usage\n\n## Argv Shorthands\n\nWe can define shorthands with the option `options.shorthands`.\n\n```js\nvar shorthands = {\n\t// if `String`, define a shorthand for a key name\n\tc: 'cwd',\n\t// if `Array`, define a pattern slice of argv\n\tnr: ['--no-recursive'],\n\t// if `Object`, define a specific value\n\tr3: {\n\t\tretry: 3,\n\t\tstrict: false\n\t}\n};\nclean({\n\tshorthands: shorthands\n}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \n// notice that '-nr' will be considered as '-n -r'\n// The result is:\n// {\n//\t\tcwd: 'abc',\n//\t\trecursive: false,\n//\t\tretry: 3,\n//\t\tstrict: false \n// }\n```\n\n## Types\n\n```js\nclean({\n\tschema: {\n\t\tcwd: {\n\t\t\ttype: require('path')\n\t\t},\n\t\t\n\t\tretry: {\n\t\t\ttype: Boolean\n\t\t}\t\t\n\t}\n}).parseArgv(\n\t['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \n\tfunction(err, results, details){\n\t\tconsole.log(results.cwd); // the `path.resolved()`d 'abc'\n\t\tconsole.log(results.retry === false); // is a boolean, not a string\n\t}\n)\n```\n\nHow to extend a custom type ? See the \"advanced section\".\n\n## Validators and Setters\n\nValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\n\nYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\n\n```sh\nnode example/clean.js --username guest\n```\n\n\n\n# Programatical Details\n\n## constructor: clean(schema, options)\n\n\n### options\n\n#### options.offset `Number=`\n\nThe offset from which the parser should start to parse. Optional. Default to `2`.\n\n#### options.shorthands `Object=`\n\nThe shorthands used to parse the argv.\n\n#### options.schema `Object=`\n\nThe schema used to clean the given object or the parsred argv\n\n#### options.check_all `Boolean=false`\n\n#### options.parallel `Boolean=false`\n\n#### options.limit `Boolean=false`\n\n\n## .argv(argv)\n\nParses the argument vector, without cleaning the data.\n\n### argv `Array`\n\n### returns `Object`\n\nThe parsed object with shorthand rules applied.\n\n\n## .clean(data, callback)\n\nCleans the given data according to the `schema`.\n\n### data `Object`\n\nThe given data.\n\n### callback `function(err, results, details)`\n\n\n## .parseArgv(argv, callback)\n\nParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\n\nThis method is equivalent to `c.clean(c.argv(argv), callback)`.\n\n# Advanced Section\n\n## .registerType(type, typeDef)\n\n\n\n\n\n\n","_id":"clean@2.1.1","dist":{"shasum":"f78cb9f6a9b3156e537fc2cbb7caf271636ecb09","tarball":"http://localhost:1337/clean/-/clean-2.1.1.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"2.1.2":{"name":"clean","version":"2.1.2","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![NPM version](https://badge.fury.io/js/clean.png)](http://badge.fury.io/js/clean)\n[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\n\n# clean\n\nClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\n\n- fully extendable types\n- shorthands\n- validatiors\n- setters\n\n# Installation and Usage\n\n```sh\nnpm install clean --save\n```\n\n```js\nvar clean = require('clean')(options);\n```\n\n# Usage\n\n## Argv Shorthands\n\nWe can define shorthands with the option `options.shorthands`.\n\n```js\nvar shorthands = {\n\t// if `String`, define a shorthand for a key name\n\tc: 'cwd',\n\t// if `Array`, define a pattern slice of argv\n\tnr: ['--no-recursive'],\n\t// if `Object`, define a specific value\n\tr3: {\n\t\tretry: 3,\n\t\tstrict: false\n\t}\n};\nclean({\n\tshorthands: shorthands\n}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \n// notice that '-nr' will be considered as '-n -r'\n// The result is:\n// {\n//\t\tcwd: 'abc',\n//\t\trecursive: false,\n//\t\tretry: 3,\n//\t\tstrict: false \n// }\n```\n\n## Types\n\n```js\nclean({\n\tschema: {\n\t\tcwd: {\n\t\t\ttype: require('path')\n\t\t},\n\t\t\n\t\tretry: {\n\t\t\ttype: Boolean\n\t\t}\t\t\n\t}\n}).parseArgv(\n\t['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \n\tfunction(err, results, details){\n\t\tconsole.log(results.cwd); // the `path.resolved()`d 'abc'\n\t\tconsole.log(results.retry === false); // is a boolean, not a string\n\t}\n)\n```\n\nHow to extend a custom type ? See the \"advanced section\".\n\n## Validators and Setters\n\nValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\n\nYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\n\n```sh\nnode example/clean.js --username guest\n```\n\n\n\n# Programatical Details\n\n## constructor: clean(schema, options)\n\n\n### options\n\n#### options.offset `Number=`\n\nThe offset from which the parser should start to parse. Optional. Default to `2`.\n\n#### options.shorthands `Object=`\n\nThe shorthands used to parse the argv.\n\n#### options.schema `Object=`\n\nThe schema used to clean the given object or the parsred argv\n\n#### options.check_all `Boolean=false`\n\n#### options.parallel `Boolean=false`\n\n#### options.limit `Boolean=false`\n\n\n## .argv(argv)\n\nParses the argument vector, without cleaning the data.\n\n### argv `Array`\n\n### returns `Object`\n\nThe parsed object with shorthand rules applied.\n\n\n## .clean(data, callback)\n\nCleans the given data according to the `schema`.\n\n### data `Object`\n\nThe given data.\n\n### callback `function(err, results, details)`\n\n\n## .parseArgv(argv, callback)\n\nParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\n\nThis method is equivalent to `c.clean(c.argv(argv), callback)`.\n\n# Advanced Section\n\n## .registerType(type, typeDef)\n\n\n\n\n\n\n","_id":"clean@2.1.2","dist":{"shasum":"1b331a23e2352a0ef4e145a72cfce1b461f36c41","tarball":"http://localhost:1337/clean/-/clean-2.1.2.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"2.1.3":{"name":"clean","version":"2.1.3","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![NPM version](https://badge.fury.io/js/clean.png)](http://badge.fury.io/js/clean)\n[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\n\n# clean\n\nClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\n\n- fully extendable types\n- shorthands\n- validatiors\n- setters\n\n# Installation and Usage\n\n```sh\nnpm install clean --save\n```\n\n```js\nvar clean = require('clean')(options);\n```\n\n# Usage\n\n## Argv Shorthands\n\nWe can define shorthands with the option `options.shorthands`.\n\n```js\nvar shorthands = {\n\t// if `String`, define a shorthand for a key name\n\tc: 'cwd',\n\t// if `Array`, define a pattern slice of argv\n\tnr: ['--no-recursive'],\n\t// if `Object`, define a specific value\n\tr3: {\n\t\tretry: 3,\n\t\tstrict: false\n\t}\n};\nclean({\n\tshorthands: shorthands\n}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \n// notice that '-nr' will be considered as '-n -r'\n// The result is:\n// {\n//\t\tcwd: 'abc',\n//\t\trecursive: false,\n//\t\tretry: 3,\n//\t\tstrict: false \n// }\n```\n\n## Types\n\n```js\nclean({\n\tschema: {\n\t\tcwd: {\n\t\t\ttype: require('path')\n\t\t},\n\t\t\n\t\tretry: {\n\t\t\ttype: Boolean\n\t\t}\t\t\n\t}\n}).parseArgv(\n\t['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \n\tfunction(err, results, details){\n\t\tconsole.log(results.cwd); // the `path.resolved()`d 'abc'\n\t\tconsole.log(results.retry === false); // is a boolean, not a string\n\t}\n)\n```\n\nHow to extend a custom type ? See the \"advanced section\".\n\n## Validators and Setters\n\nValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\n\nYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\n\n```sh\nnode example/clean.js --username guest\n```\n\n\n\n# Programatical Details\n\n## constructor: clean(schema, options)\n\n\n### options\n\n#### options.offset `Number=`\n\nThe offset from which the parser should start to parse. Optional. Default to `2`.\n\n#### options.shorthands `Object=`\n\nThe shorthands used to parse the argv.\n\n#### options.schema `Object=`\n\nThe schema used to clean the given object or the parsred argv\n\n#### options.check_all `Boolean=false`\n\n#### options.parallel `Boolean=false`\n\n#### options.limit `Boolean=false`\n\n\n## .argv(argv)\n\nParses the argument vector, without cleaning the data.\n\n### argv `Array`\n\n### returns `Object`\n\nThe parsed object with shorthand rules applied.\n\n\n## .clean(data, callback)\n\nCleans the given data according to the `schema`.\n\n### data `Object`\n\nThe given data.\n\n### callback `function(err, results, details)`\n\n\n## .parseArgv(argv, callback)\n\nParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\n\nThis method is equivalent to `c.clean(c.argv(argv), callback)`.\n\n# Advanced Section\n\n## .registerType(type, typeDef)\n\n\n\n\n\n\n","_id":"clean@2.1.3","dist":{"shasum":"b7cc64b5f6254daed3a285ae6845a826f1e16c71","tarball":"http://localhost:1337/clean/-/clean-2.1.3.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"2.1.4":{"name":"clean","version":"2.1.4","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![NPM version](https://badge.fury.io/js/clean.png)](http://badge.fury.io/js/clean)\n[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\n\n# clean\n\nClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\n\n- fully extendable types\n- shorthands\n- validatiors\n- setters\n\n# Installation and Usage\n\n```sh\nnpm install clean --save\n```\n\n```js\nvar clean = require('clean')(options);\n```\n\n# Usage\n\n## Argv Shorthands\n\nWe can define shorthands with the option `options.shorthands`.\n\n```js\nvar shorthands = {\n\t// if `String`, define a shorthand for a key name\n\tc: 'cwd',\n\t// if `Array`, define a pattern slice of argv\n\tnr: ['--no-recursive'],\n\t// if `Object`, define a specific value\n\tr3: {\n\t\tretry: 3,\n\t\tstrict: false\n\t}\n};\nclean({\n\tshorthands: shorthands\n}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \n// notice that '-nr' will be considered as '-n -r'\n// The result is:\n// {\n//\t\tcwd: 'abc',\n//\t\trecursive: false,\n//\t\tretry: 3,\n//\t\tstrict: false \n// }\n```\n\n## Types\n\n```js\nclean({\n\tschema: {\n\t\tcwd: {\n\t\t\ttype: require('path')\n\t\t},\n\t\t\n\t\tretry: {\n\t\t\ttype: Boolean\n\t\t}\t\t\n\t}\n}).parseArgv(\n\t['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \n\tfunction(err, results, details){\n\t\tconsole.log(results.cwd); // the `path.resolved()`d 'abc'\n\t\tconsole.log(results.retry === false); // is a boolean, not a string\n\t}\n)\n```\n\nHow to extend a custom type ? See the \"advanced section\".\n\n## Validators and Setters\n\nValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\n\nYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\n\n```sh\nnode example/clean.js --username guest\n```\n\n\n\n# Programatical Details\n\n## constructor: clean(schema, options)\n\n\n### options\n\n#### options.offset `Number=`\n\nThe offset from which the parser should start to parse. Optional. Default to `2`.\n\n#### options.shorthands `Object=`\n\nThe shorthands used to parse the argv.\n\n#### options.schema `Object=`\n\nThe schema used to clean the given object or the parsred argv\n\n#### options.check_all `Boolean=false`\n\n#### options.parallel `Boolean=false`\n\n#### options.limit `Boolean=false`\n\n\n## .argv(argv)\n\nParses the argument vector, without cleaning the data.\n\n### argv `Array`\n\n### returns `Object`\n\nThe parsed object with shorthand rules applied.\n\n\n## .clean(data, callback)\n\nCleans the given data according to the `schema`.\n\n### data `Object`\n\nThe given data.\n\n### callback `function(err, results, details)`\n\n\n## .parseArgv(argv, callback)\n\nParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\n\nThis method is equivalent to `c.clean(c.argv(argv), callback)`.\n\n# Advanced Section\n\n## .registerType(type, typeDef)\n\n\n\n\n\n\n","_id":"clean@2.1.4","dist":{"shasum":"4c93d479f635b64e0df1230729811030b71ed2e0","tarball":"http://localhost:1337/clean/-/clean-2.1.4.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"2.1.5":{"name":"clean","version":"2.1.5","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![NPM version](https://badge.fury.io/js/clean.png)](http://badge.fury.io/js/clean)\n[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\n\n# clean\n\nClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\n\n- fully extendable types\n- shorthands\n- validatiors\n- setters\n\n# Installation and Usage\n\n```sh\nnpm install clean --save\n```\n\n```js\nvar clean = require('clean')(options);\n```\n\n# Usage\n\n## Argv Shorthands\n\nWe can define shorthands with the option `options.shorthands`.\n\n```js\nvar shorthands = {\n\t// if `String`, define a shorthand for a key name\n\tc: 'cwd',\n\t// if `Array`, define a pattern slice of argv\n\tnr: ['--no-recursive'],\n\t// if `Object`, define a specific value\n\tr3: {\n\t\tretry: 3,\n\t\tstrict: false\n\t}\n};\nclean({\n\tshorthands: shorthands\n}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \n// notice that '-nr' will be considered as '-n -r'\n// The result is:\n// {\n//\t\tcwd: 'abc',\n//\t\trecursive: false,\n//\t\tretry: 3,\n//\t\tstrict: false \n// }\n```\n\n## Types\n\n```js\nclean({\n\tschema: {\n\t\tcwd: {\n\t\t\ttype: require('path')\n\t\t},\n\t\t\n\t\tretry: {\n\t\t\ttype: Boolean\n\t\t}\t\t\n\t}\n}).parseArgv(\n\t['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \n\tfunction(err, results, details){\n\t\tconsole.log(results.cwd); // the `path.resolved()`d 'abc'\n\t\tconsole.log(results.retry === false); // is a boolean, not a string\n\t}\n)\n```\n\nHow to extend a custom type ? See the \"advanced section\".\n\n## Validators and Setters\n\nValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\n\nYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\n\n```sh\nnode example/clean.js --username guest\n```\n\n\n\n# Programatical Details\n\n## constructor: clean(schema, options)\n\n\n### options\n\n#### options.offset `Number=`\n\nThe offset from which the parser should start to parse. Optional. Default to `2`.\n\n#### options.shorthands `Object=`\n\nThe shorthands used to parse the argv.\n\n#### options.schema `Object=`\n\nThe schema used to clean the given object or the parsred argv\n\n#### options.check_all `Boolean=false`\n\n#### options.parallel `Boolean=false`\n\n#### options.limit `Boolean=false`\n\n\n## .argv(argv)\n\nParses the argument vector, without cleaning the data.\n\n### argv `Array`\n\n### returns `Object`\n\nThe parsed object with shorthand rules applied.\n\n\n## .clean(data, callback)\n\nCleans the given data according to the `schema`.\n\n### data `Object`\n\nThe given data.\n\n### callback `function(err, results, details)`\n\n\n## .parseArgv(argv, callback)\n\nParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\n\nThis method is equivalent to `c.clean(c.argv(argv), callback)`.\n\n# Advanced Section\n\n## .registerType(type, typeDef)\n\n\n\n\n\n\n","_id":"clean@2.1.5","dist":{"shasum":"62c230d6c08ab4d21388b9cbdfd2519bfd43bde9","tarball":"http://localhost:1337/clean/-/clean-2.1.5.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}},"2.1.6":{"name":"clean","version":"2.1.6","description":"clean parses and santitize argv or options for node, supporting fully extendable types, shorthands, validatiors and setters.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"keywords":["argv","parser","argument-vector","cleaner","simple"],"author":{"name":"Kael"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/kaelzhang/node-clean/issues"},"dependencies":{"checker":"~0.5.1","minimist":"~0.0.5"},"devDependencies":{"mocha":"~1.13.0","chai":"~1.8.0"},"readme":"[![NPM version](https://badge.fury.io/js/clean.png)](http://badge.fury.io/js/clean)\n[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\n[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\n\n# clean\n\nClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\n\n- fully extendable types\n- shorthands\n- validatiors\n- setters\n\n# Installation and Usage\n\n```sh\nnpm install clean --save\n```\n\n```js\nvar clean = require('clean')(options);\n```\n\n# Usage\n\n## Argv Shorthands\n\nWe can define shorthands with the option `options.shorthands`.\n\n```js\nvar shorthands = {\n\t// if `String`, define a shorthand for a key name\n\tc: 'cwd',\n\t// if `Array`, define a pattern slice of argv\n\tnr: ['--no-recursive'],\n\t// if `Object`, define a specific value\n\tr3: {\n\t\tretry: 3,\n\t\tstrict: false\n\t}\n};\nclean({\n\tshorthands: shorthands\n}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \n// notice that '-nr' will be considered as '-n -r'\n// The result is:\n// {\n//\t\tcwd: 'abc',\n//\t\trecursive: false,\n//\t\tretry: 3,\n//\t\tstrict: false \n// }\n```\n\n## Types\n\n```js\nclean({\n\tschema: {\n\t\tcwd: {\n\t\t\ttype: require('path')\n\t\t},\n\t\t\n\t\tretry: {\n\t\t\ttype: Boolean\n\t\t}\t\t\n\t}\n}).parseArgv(\n\t['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \n\tfunction(err, results, details){\n\t\tconsole.log(results.cwd); // the `path.resolved()`d 'abc'\n\t\tconsole.log(results.retry === false); // is a boolean, not a string\n\t}\n)\n```\n\nHow to extend a custom type ? See the \"advanced section\".\n\n## Validators and Setters\n\nValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\n\nYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\n\n```sh\nnode example/clean.js --username guest\n```\n\n\n\n# Programatical Details\n\n## constructor: clean(schema, options)\n\n\n### options\n\n#### options.offset `Number=`\n\nThe offset from which the parser should start to parse. Optional. Default to `2`.\n\n#### options.shorthands `Object=`\n\nThe shorthands used to parse the argv.\n\n#### options.schema `Object=`\n\nThe schema used to clean the given object or the parsred argv\n\n#### options.check_all `Boolean=false`\n\n#### options.parallel `Boolean=false`\n\n#### options.limit `Boolean=false`\n\n\n## .argv(argv)\n\nParses the argument vector, without cleaning the data.\n\n### argv `Array`\n\n### returns `Object`\n\nThe parsed object with shorthand rules applied.\n\n\n## .clean(data, callback)\n\nCleans the given data according to the `schema`.\n\n### data `Object`\n\nThe given data.\n\n### callback `function(err, results, details)`\n\n\n## .parseArgv(argv, callback)\n\nParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\n\nThis method is equivalent to `c.clean(c.argv(argv), callback)`.\n\n# Advanced Section\n\n## .registerType(type, typeDef)\n\n\n\n\n\n\n","_id":"clean@2.1.6","dist":{"shasum":"41c80b2b6f5432c60cddb81932ab56563b444f52","tarball":"http://localhost:1337/clean/-/clean-2.1.6.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{}}},"readme":"ERROR: No README data found!","maintainers":[{"name":"kael","email":"i@kael.me"}],"time":{"modified":"2013-10-29T10:27:09.584Z","created":"2013-10-09T14:58:35.029Z","0.0.0":"2013-10-09T14:58:56.786Z","1.1.3":"2013-10-09T17:11:53.515Z","1.1.4":"2013-10-09T17:14:02.537Z","2.1.1":"2013-10-10T04:10:32.004Z","2.1.2":"2013-10-14T13:43:09.309Z","2.1.3":"2013-10-14T15:49:01.158Z","2.1.4":"2013-10-17T03:15:37.028Z","2.1.5":"2013-10-17T03:21:04.145Z","2.1.6":"2013-10-29T10:27:09.584Z"},"author":{"name":"Kael"},"repository":{"type":"git","url":"git@github.com:kaelzhang/node-clean.git"},"_attachments":{}}