{"_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://registry.npmjs.org/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)\u000a\u000a# Argv-parser\u000a\u000a> Argv-parser is a small and simple node.js module to parse `process.argv`\u000a\u000aArgv-parser is designed to be simple and will do nothing about:\u000a\u000a- option registration\u000a- description of options\u000a- output\u000a\u000a## Installation\u000a\u000a```sh\u000anpm install argv-parser --save\u000a```\u000a\u000a## Usage\u000a\u000a```js\u000avar parser = require('argv-parser');\u000a```\u000a\u000a## parser.parse(argv, options)\u000a\u000aParse argument vector (argv) or something like argv.\u000a\u000a##### Returns `ret` `Object`\u000a\u000a- parsed: `Object` the parsed object\u000a- warnings: `Object` the warnings of each option. If not exists, `ret.warning` will be an empty object\u000a- errors: `Object` the errors of each option.\u000a\u000a##### argv `Array`\u000a\u000a`process.argv` or something like that.\u000a\u000a##### options `Object`\u000a\u000a- rules: `Object` an extended `nopt` rules\u000a- offset: `Number` (optional, default to `2`) the offset from which the parser should start to parse.\u000a\u000a\u000a## parser.clean(data, options)\u000a\u000a##### Returns\u000a\u000aThe same as `parser.parse`\u000a\u000a##### options `Object`\u000a\u000a- rules: `Object`\u000a- types: `Object` (optional) type definitions. For most cases, you needn't this option\u000a\u000a\u000a## options.rules\u000a\u000a\u000a## Example\u000a\u000atest.js\u000a\u000a```js\u000avar rules = {\u000a    open: {\u000a        type: Boolean,\u000a        value: true\u000a    },\u000a\u000a    port: {\u000a        type: Number,\u000a        short: 'p',\u000a        value: function(port, parsed, tool) {\u000a            if(!port){\u000a                port = 9230;\u000a            }\u000a\u000a            if(port < 8000){\u000a                tool.warn('port < 8000 which is dangerous');\u000a                \u000a                if(port < 1000){\u000a                \u0009tool.error('port < 100 which is forbidden');\u000a        \u0009\u0009\u0009return;\u000a                }\u000a            }\u000a\u000a            return port;\u000a        }\u000a    },\u000a\u000a    html: {\u000a        type: 'html',\u000a    },\u000a\u000a    name: {\u000a        type: String\u000a    }\u000a};\u000a\u000avar data = parser.parse(process.argv, {\u000a\u0009rules: rules\u000a});\u000a```\u000a\u000aDefault values:\u000a\u000a```\u000a$ node test.js\u000a> data.parsed.open; // true\u000a> data.parsed.port; // 9230\u000a\u000a```\u000a\u000aType limitation:\u000a\u000a```\u000a$ node test.js --port 8888 --no-open --name name<script>alert(123)</script>\u000a> data.parsed.open; // false\u000a> data.parsed.port; // 8888\u000a> data.parsed.name; // 'namealert(123)'; -> stripped\u000a> data.errors;      // {}\u000a> data.warnings;    // {}\u000a```\u000a\u000aWarnings and errors:\u000a\u000a```\u000a$ node test.js --port 888 --no-open --name name<script>alert(123)</script>\u000a> data.parsed.open; // false\u000a> data.parsed.port; // undefined; -> error\u000a> data.parsed.name; // 'name<script>alert(123)</script>'\u000a> data.errors;      // {port: ['port < 100 which is forbidden']}\u000a> data.warnings;    // {port: ['port < 8000 which is dangerous']}\u000a```\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@1.1.4","dist":{"shasum":"5fe3f1d48a22842316eba0a19c51f26428015c80","tarball":"http://registry.npmjs.org/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)\u000a\u000a# clean\u000a\u000aClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\u000a\u000a- fully extendable types\u000a- shorthands\u000a- validatiors\u000a- setters\u000a\u000a# Installation and Usage\u000a\u000a```sh\u000anpm install clean --save\u000a```\u000a\u000a```js\u000avar clean = require('clean')(options);\u000a```\u000a\u000a# Usage\u000a\u000a## Argv Shorthands\u000a\u000aWe can define shorthands with the option `options.shorthands`.\u000a\u000a```js\u000avar shorthands = {\u000a\u0009// if `String`, define a shorthand for a key name\u000a\u0009c: 'cwd',\u000a\u0009// if `Array`, define a pattern slice of argv\u000a\u0009nr: ['--no-recursive'],\u000a\u0009// if `Object`, define a specific value\u000a\u0009r3: {\u000a\u0009\u0009retry: 3,\u000a\u0009\u0009strict: false\u000a\u0009}\u000a};\u000aclean({\u000a\u0009shorthands: shorthands\u000a}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \u000a// notice that '-nr' will be considered as '-n -r'\u000a// The result is:\u000a// {\u000a//\u0009\u0009cwd: 'abc',\u000a//\u0009\u0009recursive: false,\u000a//\u0009\u0009retry: 3,\u000a//\u0009\u0009strict: false \u000a// }\u000a```\u000a\u000a## Types\u000a\u000a```js\u000aclean({\u000a\u0009schema: {\u000a\u0009\u0009cwd: {\u000a\u0009\u0009\u0009type: require('path')\u000a\u0009\u0009},\u000a\u0009\u0009\u000a\u0009\u0009retry: {\u000a\u0009\u0009\u0009type: Boolean\u000a\u0009\u0009}\u0009\u0009\u000a\u0009}\u000a}).parseArgv(\u000a\u0009['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \u000a\u0009function(err, results, details){\u000a\u0009\u0009console.log(results.cwd); // the `path.resolved()`d 'abc'\u000a\u0009\u0009console.log(results.retry === false); // is a boolean, not a string\u000a\u0009}\u000a)\u000a```\u000a\u000aHow to extend a custom type ? See the \"advanced section\".\u000a\u000a## Validators and Setters\u000a\u000aValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\u000a\u000aYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\u000a\u000a```sh\u000anode example/clean.js --username guest\u000a```\u000a\u000a\u000a\u000a# Programatical Details\u000a\u000a## constructor: clean(schema, options)\u000a\u000a\u000a### options\u000a\u000a#### options.offset `Number=`\u000a\u000aThe offset from which the parser should start to parse. Optional. Default to `2`.\u000a\u000a#### options.shorthands `Object=`\u000a\u000aThe shorthands used to parse the argv.\u000a\u000a#### options.schema `Object=`\u000a\u000aThe schema used to clean the given object or the parsred argv\u000a\u000a#### options.check_all `Boolean=false`\u000a\u000a#### options.parallel `Boolean=false`\u000a\u000a#### options.limit `Boolean=false`\u000a\u000a\u000a## .argv(argv)\u000a\u000aParses the argument vector, without cleaning the data.\u000a\u000a### argv `Array`\u000a\u000a### returns `Object`\u000a\u000aThe parsed object with shorthand rules applied.\u000a\u000a\u000a## .clean(data, callback)\u000a\u000aCleans the given data according to the `schema`.\u000a\u000a### data `Object`\u000a\u000aThe given data.\u000a\u000a### callback `function(err, results, details)`\u000a\u000a\u000a## .parseArgv(argv, callback)\u000a\u000aParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\u000a\u000aThis method is equivalent to `c.clean(c.argv(argv), callback)`.\u000a\u000a# Advanced Section\u000a\u000a## .registerType(type, typeDef)\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@2.1.1","dist":{"shasum":"f78cb9f6a9b3156e537fc2cbb7caf271636ecb09","tarball":"http://registry.npmjs.org/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)\u000a[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\u000a[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\u000a\u000a# clean\u000a\u000aClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\u000a\u000a- fully extendable types\u000a- shorthands\u000a- validatiors\u000a- setters\u000a\u000a# Installation and Usage\u000a\u000a```sh\u000anpm install clean --save\u000a```\u000a\u000a```js\u000avar clean = require('clean')(options);\u000a```\u000a\u000a# Usage\u000a\u000a## Argv Shorthands\u000a\u000aWe can define shorthands with the option `options.shorthands`.\u000a\u000a```js\u000avar shorthands = {\u000a\u0009// if `String`, define a shorthand for a key name\u000a\u0009c: 'cwd',\u000a\u0009// if `Array`, define a pattern slice of argv\u000a\u0009nr: ['--no-recursive'],\u000a\u0009// if `Object`, define a specific value\u000a\u0009r3: {\u000a\u0009\u0009retry: 3,\u000a\u0009\u0009strict: false\u000a\u0009}\u000a};\u000aclean({\u000a\u0009shorthands: shorthands\u000a}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \u000a// notice that '-nr' will be considered as '-n -r'\u000a// The result is:\u000a// {\u000a//\u0009\u0009cwd: 'abc',\u000a//\u0009\u0009recursive: false,\u000a//\u0009\u0009retry: 3,\u000a//\u0009\u0009strict: false \u000a// }\u000a```\u000a\u000a## Types\u000a\u000a```js\u000aclean({\u000a\u0009schema: {\u000a\u0009\u0009cwd: {\u000a\u0009\u0009\u0009type: require('path')\u000a\u0009\u0009},\u000a\u0009\u0009\u000a\u0009\u0009retry: {\u000a\u0009\u0009\u0009type: Boolean\u000a\u0009\u0009}\u0009\u0009\u000a\u0009}\u000a}).parseArgv(\u000a\u0009['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \u000a\u0009function(err, results, details){\u000a\u0009\u0009console.log(results.cwd); // the `path.resolved()`d 'abc'\u000a\u0009\u0009console.log(results.retry === false); // is a boolean, not a string\u000a\u0009}\u000a)\u000a```\u000a\u000aHow to extend a custom type ? See the \"advanced section\".\u000a\u000a## Validators and Setters\u000a\u000aValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\u000a\u000aYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\u000a\u000a```sh\u000anode example/clean.js --username guest\u000a```\u000a\u000a\u000a\u000a# Programatical Details\u000a\u000a## constructor: clean(schema, options)\u000a\u000a\u000a### options\u000a\u000a#### options.offset `Number=`\u000a\u000aThe offset from which the parser should start to parse. Optional. Default to `2`.\u000a\u000a#### options.shorthands `Object=`\u000a\u000aThe shorthands used to parse the argv.\u000a\u000a#### options.schema `Object=`\u000a\u000aThe schema used to clean the given object or the parsred argv\u000a\u000a#### options.check_all `Boolean=false`\u000a\u000a#### options.parallel `Boolean=false`\u000a\u000a#### options.limit `Boolean=false`\u000a\u000a\u000a## .argv(argv)\u000a\u000aParses the argument vector, without cleaning the data.\u000a\u000a### argv `Array`\u000a\u000a### returns `Object`\u000a\u000aThe parsed object with shorthand rules applied.\u000a\u000a\u000a## .clean(data, callback)\u000a\u000aCleans the given data according to the `schema`.\u000a\u000a### data `Object`\u000a\u000aThe given data.\u000a\u000a### callback `function(err, results, details)`\u000a\u000a\u000a## .parseArgv(argv, callback)\u000a\u000aParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\u000a\u000aThis method is equivalent to `c.clean(c.argv(argv), callback)`.\u000a\u000a# Advanced Section\u000a\u000a## .registerType(type, typeDef)\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@2.1.2","dist":{"shasum":"1b331a23e2352a0ef4e145a72cfce1b461f36c41","tarball":"http://registry.npmjs.org/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)\u000a[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\u000a[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\u000a\u000a# clean\u000a\u000aClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\u000a\u000a- fully extendable types\u000a- shorthands\u000a- validatiors\u000a- setters\u000a\u000a# Installation and Usage\u000a\u000a```sh\u000anpm install clean --save\u000a```\u000a\u000a```js\u000avar clean = require('clean')(options);\u000a```\u000a\u000a# Usage\u000a\u000a## Argv Shorthands\u000a\u000aWe can define shorthands with the option `options.shorthands`.\u000a\u000a```js\u000avar shorthands = {\u000a\u0009// if `String`, define a shorthand for a key name\u000a\u0009c: 'cwd',\u000a\u0009// if `Array`, define a pattern slice of argv\u000a\u0009nr: ['--no-recursive'],\u000a\u0009// if `Object`, define a specific value\u000a\u0009r3: {\u000a\u0009\u0009retry: 3,\u000a\u0009\u0009strict: false\u000a\u0009}\u000a};\u000aclean({\u000a\u0009shorthands: shorthands\u000a}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \u000a// notice that '-nr' will be considered as '-n -r'\u000a// The result is:\u000a// {\u000a//\u0009\u0009cwd: 'abc',\u000a//\u0009\u0009recursive: false,\u000a//\u0009\u0009retry: 3,\u000a//\u0009\u0009strict: false \u000a// }\u000a```\u000a\u000a## Types\u000a\u000a```js\u000aclean({\u000a\u0009schema: {\u000a\u0009\u0009cwd: {\u000a\u0009\u0009\u0009type: require('path')\u000a\u0009\u0009},\u000a\u0009\u0009\u000a\u0009\u0009retry: {\u000a\u0009\u0009\u0009type: Boolean\u000a\u0009\u0009}\u0009\u0009\u000a\u0009}\u000a}).parseArgv(\u000a\u0009['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \u000a\u0009function(err, results, details){\u000a\u0009\u0009console.log(results.cwd); // the `path.resolved()`d 'abc'\u000a\u0009\u0009console.log(results.retry === false); // is a boolean, not a string\u000a\u0009}\u000a)\u000a```\u000a\u000aHow to extend a custom type ? See the \"advanced section\".\u000a\u000a## Validators and Setters\u000a\u000aValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\u000a\u000aYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\u000a\u000a```sh\u000anode example/clean.js --username guest\u000a```\u000a\u000a\u000a\u000a# Programatical Details\u000a\u000a## constructor: clean(schema, options)\u000a\u000a\u000a### options\u000a\u000a#### options.offset `Number=`\u000a\u000aThe offset from which the parser should start to parse. Optional. Default to `2`.\u000a\u000a#### options.shorthands `Object=`\u000a\u000aThe shorthands used to parse the argv.\u000a\u000a#### options.schema `Object=`\u000a\u000aThe schema used to clean the given object or the parsred argv\u000a\u000a#### options.check_all `Boolean=false`\u000a\u000a#### options.parallel `Boolean=false`\u000a\u000a#### options.limit `Boolean=false`\u000a\u000a\u000a## .argv(argv)\u000a\u000aParses the argument vector, without cleaning the data.\u000a\u000a### argv `Array`\u000a\u000a### returns `Object`\u000a\u000aThe parsed object with shorthand rules applied.\u000a\u000a\u000a## .clean(data, callback)\u000a\u000aCleans the given data according to the `schema`.\u000a\u000a### data `Object`\u000a\u000aThe given data.\u000a\u000a### callback `function(err, results, details)`\u000a\u000a\u000a## .parseArgv(argv, callback)\u000a\u000aParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\u000a\u000aThis method is equivalent to `c.clean(c.argv(argv), callback)`.\u000a\u000a# Advanced Section\u000a\u000a## .registerType(type, typeDef)\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@2.1.3","dist":{"shasum":"b7cc64b5f6254daed3a285ae6845a826f1e16c71","tarball":"http://registry.npmjs.org/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)\u000a[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\u000a[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\u000a\u000a# clean\u000a\u000aClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\u000a\u000a- fully extendable types\u000a- shorthands\u000a- validatiors\u000a- setters\u000a\u000a# Installation and Usage\u000a\u000a```sh\u000anpm install clean --save\u000a```\u000a\u000a```js\u000avar clean = require('clean')(options);\u000a```\u000a\u000a# Usage\u000a\u000a## Argv Shorthands\u000a\u000aWe can define shorthands with the option `options.shorthands`.\u000a\u000a```js\u000avar shorthands = {\u000a\u0009// if `String`, define a shorthand for a key name\u000a\u0009c: 'cwd',\u000a\u0009// if `Array`, define a pattern slice of argv\u000a\u0009nr: ['--no-recursive'],\u000a\u0009// if `Object`, define a specific value\u000a\u0009r3: {\u000a\u0009\u0009retry: 3,\u000a\u0009\u0009strict: false\u000a\u0009}\u000a};\u000aclean({\u000a\u0009shorthands: shorthands\u000a}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \u000a// notice that '-nr' will be considered as '-n -r'\u000a// The result is:\u000a// {\u000a//\u0009\u0009cwd: 'abc',\u000a//\u0009\u0009recursive: false,\u000a//\u0009\u0009retry: 3,\u000a//\u0009\u0009strict: false \u000a// }\u000a```\u000a\u000a## Types\u000a\u000a```js\u000aclean({\u000a\u0009schema: {\u000a\u0009\u0009cwd: {\u000a\u0009\u0009\u0009type: require('path')\u000a\u0009\u0009},\u000a\u0009\u0009\u000a\u0009\u0009retry: {\u000a\u0009\u0009\u0009type: Boolean\u000a\u0009\u0009}\u0009\u0009\u000a\u0009}\u000a}).parseArgv(\u000a\u0009['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \u000a\u0009function(err, results, details){\u000a\u0009\u0009console.log(results.cwd); // the `path.resolved()`d 'abc'\u000a\u0009\u0009console.log(results.retry === false); // is a boolean, not a string\u000a\u0009}\u000a)\u000a```\u000a\u000aHow to extend a custom type ? See the \"advanced section\".\u000a\u000a## Validators and Setters\u000a\u000aValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\u000a\u000aYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\u000a\u000a```sh\u000anode example/clean.js --username guest\u000a```\u000a\u000a\u000a\u000a# Programatical Details\u000a\u000a## constructor: clean(schema, options)\u000a\u000a\u000a### options\u000a\u000a#### options.offset `Number=`\u000a\u000aThe offset from which the parser should start to parse. Optional. Default to `2`.\u000a\u000a#### options.shorthands `Object=`\u000a\u000aThe shorthands used to parse the argv.\u000a\u000a#### options.schema `Object=`\u000a\u000aThe schema used to clean the given object or the parsred argv\u000a\u000a#### options.check_all `Boolean=false`\u000a\u000a#### options.parallel `Boolean=false`\u000a\u000a#### options.limit `Boolean=false`\u000a\u000a\u000a## .argv(argv)\u000a\u000aParses the argument vector, without cleaning the data.\u000a\u000a### argv `Array`\u000a\u000a### returns `Object`\u000a\u000aThe parsed object with shorthand rules applied.\u000a\u000a\u000a## .clean(data, callback)\u000a\u000aCleans the given data according to the `schema`.\u000a\u000a### data `Object`\u000a\u000aThe given data.\u000a\u000a### callback `function(err, results, details)`\u000a\u000a\u000a## .parseArgv(argv, callback)\u000a\u000aParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\u000a\u000aThis method is equivalent to `c.clean(c.argv(argv), callback)`.\u000a\u000a# Advanced Section\u000a\u000a## .registerType(type, typeDef)\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@2.1.4","dist":{"shasum":"4c93d479f635b64e0df1230729811030b71ed2e0","tarball":"http://registry.npmjs.org/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)\u000a[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\u000a[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\u000a\u000a# clean\u000a\u000aClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\u000a\u000a- fully extendable types\u000a- shorthands\u000a- validatiors\u000a- setters\u000a\u000a# Installation and Usage\u000a\u000a```sh\u000anpm install clean --save\u000a```\u000a\u000a```js\u000avar clean = require('clean')(options);\u000a```\u000a\u000a# Usage\u000a\u000a## Argv Shorthands\u000a\u000aWe can define shorthands with the option `options.shorthands`.\u000a\u000a```js\u000avar shorthands = {\u000a\u0009// if `String`, define a shorthand for a key name\u000a\u0009c: 'cwd',\u000a\u0009// if `Array`, define a pattern slice of argv\u000a\u0009nr: ['--no-recursive'],\u000a\u0009// if `Object`, define a specific value\u000a\u0009r3: {\u000a\u0009\u0009retry: 3,\u000a\u0009\u0009strict: false\u000a\u0009}\u000a};\u000aclean({\u000a\u0009shorthands: shorthands\u000a}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \u000a// notice that '-nr' will be considered as '-n -r'\u000a// The result is:\u000a// {\u000a//\u0009\u0009cwd: 'abc',\u000a//\u0009\u0009recursive: false,\u000a//\u0009\u0009retry: 3,\u000a//\u0009\u0009strict: false \u000a// }\u000a```\u000a\u000a## Types\u000a\u000a```js\u000aclean({\u000a\u0009schema: {\u000a\u0009\u0009cwd: {\u000a\u0009\u0009\u0009type: require('path')\u000a\u0009\u0009},\u000a\u0009\u0009\u000a\u0009\u0009retry: {\u000a\u0009\u0009\u0009type: Boolean\u000a\u0009\u0009}\u0009\u0009\u000a\u0009}\u000a}).parseArgv(\u000a\u0009['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \u000a\u0009function(err, results, details){\u000a\u0009\u0009console.log(results.cwd); // the `path.resolved()`d 'abc'\u000a\u0009\u0009console.log(results.retry === false); // is a boolean, not a string\u000a\u0009}\u000a)\u000a```\u000a\u000aHow to extend a custom type ? See the \"advanced section\".\u000a\u000a## Validators and Setters\u000a\u000aValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\u000a\u000aYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\u000a\u000a```sh\u000anode example/clean.js --username guest\u000a```\u000a\u000a\u000a\u000a# Programatical Details\u000a\u000a## constructor: clean(schema, options)\u000a\u000a\u000a### options\u000a\u000a#### options.offset `Number=`\u000a\u000aThe offset from which the parser should start to parse. Optional. Default to `2`.\u000a\u000a#### options.shorthands `Object=`\u000a\u000aThe shorthands used to parse the argv.\u000a\u000a#### options.schema `Object=`\u000a\u000aThe schema used to clean the given object or the parsred argv\u000a\u000a#### options.check_all `Boolean=false`\u000a\u000a#### options.parallel `Boolean=false`\u000a\u000a#### options.limit `Boolean=false`\u000a\u000a\u000a## .argv(argv)\u000a\u000aParses the argument vector, without cleaning the data.\u000a\u000a### argv `Array`\u000a\u000a### returns `Object`\u000a\u000aThe parsed object with shorthand rules applied.\u000a\u000a\u000a## .clean(data, callback)\u000a\u000aCleans the given data according to the `schema`.\u000a\u000a### data `Object`\u000a\u000aThe given data.\u000a\u000a### callback `function(err, results, details)`\u000a\u000a\u000a## .parseArgv(argv, callback)\u000a\u000aParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\u000a\u000aThis method is equivalent to `c.clean(c.argv(argv), callback)`.\u000a\u000a# Advanced Section\u000a\u000a## .registerType(type, typeDef)\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@2.1.5","dist":{"shasum":"62c230d6c08ab4d21388b9cbdfd2519bfd43bde9","tarball":"http://registry.npmjs.org/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)\u000a[![Build Status](https://travis-ci.org/kaelzhang/node-clean.png?branch=master)](https://travis-ci.org/kaelzhang/node-clean)\u000a[![Dependency Status](https://gemnasium.com/kaelzhang/node-clean.png)](https://gemnasium.com/kaelzhang/node-clean)\u000a\u000a# clean\u000a\u000aClean is small but powerful node.js module that parses and santitize argv or options for node, supporting:\u000a\u000a- fully extendable types\u000a- shorthands\u000a- validatiors\u000a- setters\u000a\u000a# Installation and Usage\u000a\u000a```sh\u000anpm install clean --save\u000a```\u000a\u000a```js\u000avar clean = require('clean')(options);\u000a```\u000a\u000a# Usage\u000a\u000a## Argv Shorthands\u000a\u000aWe can define shorthands with the option `options.shorthands`.\u000a\u000a```js\u000avar shorthands = {\u000a\u0009// if `String`, define a shorthand for a key name\u000a\u0009c: 'cwd',\u000a\u0009// if `Array`, define a pattern slice of argv\u000a\u0009nr: ['--no-recursive'],\u000a\u0009// if `Object`, define a specific value\u000a\u0009r3: {\u000a\u0009\u0009retry: 3,\u000a\u0009\u0009strict: false\u000a\u0009}\u000a};\u000aclean({\u000a\u0009shorthands: shorthands\u000a}).argv(['node', 'xxx', '-c', 'abc', '--nr', '--r3']); \u000a// notice that '-nr' will be considered as '-n -r'\u000a// The result is:\u000a// {\u000a//\u0009\u0009cwd: 'abc',\u000a//\u0009\u0009recursive: false,\u000a//\u0009\u0009retry: 3,\u000a//\u0009\u0009strict: false \u000a// }\u000a```\u000a\u000a## Types\u000a\u000a```js\u000aclean({\u000a\u0009schema: {\u000a\u0009\u0009cwd: {\u000a\u0009\u0009\u0009type: require('path')\u000a\u0009\u0009},\u000a\u0009\u0009\u000a\u0009\u0009retry: {\u000a\u0009\u0009\u0009type: Boolean\u000a\u0009\u0009}\u0009\u0009\u000a\u0009}\u000a}).parseArgv(\u000a\u0009['node', 'xxx', '--cwd', 'abc', 'retry', 'false'], \u000a\u0009function(err, results, details){\u000a\u0009\u0009console.log(results.cwd); // the `path.resolved()`d 'abc'\u000a\u0009\u0009console.log(results.retry === false); // is a boolean, not a string\u000a\u0009}\u000a)\u000a```\u000a\u000aHow to extend a custom type ? See the \"advanced section\".\u000a\u000a## Validators and Setters\u000a\u000aValidators and setters of `clean` is implemented by `[checker](https://github.com/kaelzhang/node-checker)`, check the apis of `checker` for details.\u000a\u000aYou could check out the demo located at \"example/clean.js\". That is a very complicated situation of usage.\u000a\u000a```sh\u000anode example/clean.js --username guest\u000a```\u000a\u000a\u000a\u000a# Programatical Details\u000a\u000a## constructor: clean(schema, options)\u000a\u000a\u000a### options\u000a\u000a#### options.offset `Number=`\u000a\u000aThe offset from which the parser should start to parse. Optional. Default to `2`.\u000a\u000a#### options.shorthands `Object=`\u000a\u000aThe shorthands used to parse the argv.\u000a\u000a#### options.schema `Object=`\u000a\u000aThe schema used to clean the given object or the parsred argv\u000a\u000a#### options.check_all `Boolean=false`\u000a\u000a#### options.parallel `Boolean=false`\u000a\u000a#### options.limit `Boolean=false`\u000a\u000a\u000a## .argv(argv)\u000a\u000aParses the argument vector, without cleaning the data.\u000a\u000a### argv `Array`\u000a\u000a### returns `Object`\u000a\u000aThe parsed object with shorthand rules applied.\u000a\u000a\u000a## .clean(data, callback)\u000a\u000aCleans the given data according to the `schema`.\u000a\u000a### data `Object`\u000a\u000aThe given data.\u000a\u000a### callback `function(err, results, details)`\u000a\u000a\u000a## .parseArgv(argv, callback)\u000a\u000aParses argument vector (argv) or something like argv, and cleans the parsed data according to the `schema`.\u000a\u000aThis method is equivalent to `c.clean(c.argv(argv), callback)`.\u000a\u000a# Advanced Section\u000a\u000a## .registerType(type, typeDef)\u000a\u000a\u000a\u000a\u000a\u000a\u000a","_id":"clean@2.1.6","dist":{"shasum":"41c80b2b6f5432c60cddb81932ab56563b444f52","tarball":"http://registry.npmjs.org/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":{}}