{"_id":"argv","_rev":"209218","name":"argv","description":"CLI Argument Parser","dist-tags":{"latest":"0.0.2"},"maintainers":[{"name":"codenothing","email":"corey@codenothing.com"}],"time":{"modified":"2021-06-03T15:24:51.000Z","created":"2012-07-08T22:32:13.731Z","0.0.2":"2013-05-19T09:04:51.012Z","0.0.1":"2012-07-08T22:32:13.731Z"},"users":{"daspisch":true,"hutushen222":true,"karrdy":true,"cafedeaqua":true,"amurchick":true,"bapinney":true,"lichenhao":true,"vchouhan":true,"gubi":true,"dralc":true,"gtopia":true,"gurunate":true,"juangotama":true,"akabeko":true,"yuch4n":true,"alek-s":true,"joaquin.briceno":true,"exilodas":true,"xrush":true,"rafegoldberg":true,"jeremy_yang":true},"author":{"name":"Corey Hart","email":"corey@codenothing.com"},"versions":{"0.0.2":{"name":"argv","description":"CLI Argument Parser","url":"http://codenothing.github.com/argv/","keywords":["cli","argv","options"],"author":{"name":"Corey Hart","email":"corey@codenothing.com"},"version":"0.0.2","main":"./index.js","engines":{"node":">=0.6.10"},"scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"nlint":"0.0.4","munit":"0.0.5"},"readmeFilename":"README.md","_id":"argv@0.0.2","dist":{"shasum":"ecbd16f8949b157183711b1bda334f37840185ab","size":7713,"noattachment":false,"key":"/argv/-/argv-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/argv/download/argv-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"codenothing","email":"corey@codenothing.com"},"maintainers":[{"name":"codenothing","email":"corey@codenothing.com"}],"directories":{},"publish_time":1368954291012,"_hasShrinkwrap":false,"_cnpm_publish_time":1368954291012},"0.0.1":{"name":"argv","description":"CLI Argument Parser","url":"http://codenothing.github.com/argv/","keywords":["cli","argv","options"],"author":{"name":"Corey Hart","email":"corey@codenothing.com"},"version":"0.0.1","main":"./index.js","engines":{"node":">=0.6.10"},"dependencies":{},"devDependencies":{"nlint":"0.0.1"},"_npmUser":{"name":"codenothing","email":"corey@codenothing.com"},"_id":"argv@0.0.1","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"0983be279d7a97d9c1e825c953c893f0d105aa5e","size":5512,"noattachment":false,"key":"/argv/-/argv-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/argv/download/argv-0.0.1.tgz"},"maintainers":[{"name":"codenothing","email":"corey@codenothing.com"}],"directories":{},"publish_time":1341786733731,"_hasShrinkwrap":false,"_cnpm_publish_time":1341786733731}},"readme":"# argv\n\nargv is a nodejs module that does command line argument parsing.\n\n\n### Installation\n\n```bash\n$ npm install argv\n```\n\n\n### Usage\n\n```js\nvar argv = require( 'argv' );\nvar args = argv.option( options ).run();\n-> { targets: [], options: {} }\n```\n\n\n### Run\n\nRuns the argument parser on the global arguments. Custom arguments array can be used by passing into this method\n\n```js\n// Parses default arguments 'process.argv.slice( 2 )'\nargv.run();\n\n// Parses array instead\nargv.run([ '--option=123', '-o', '123' ]);\n```\n\n\n### Options\n\nargv is a strict argument parser, which means all options must be defined before parsing starts.\n\n```js\nargv.option({\n\tname: 'option',\n\tshort: 'o',\n\ttype: 'string',\n\tdescription: 'Defines an option for your script',\n\texample: \"'script --opiton=value' or 'script -o value'\"\n});\n```\n\n\n### Modules\n\nModules are nested commands for more complicated scripts. Each module has it's own set of options that\nhave to be defined independently of the root options.\n\n```js\nargv.mod({\n\tmod: 'module',\n\tdescription: 'Description of what the module is used for',\n\toptions: [ list of options ]\n});\n```\n\n\n### Types\n\nTypes convert option values to useful js objects. They are defined along with each option.\n\n* **string**: Ensure values are strings\n* **path**: Converts value into a fully resolved path.\n* **int**: Converts value into an integer\n* **float**: Converts value into a float number\n* **boolean**: Converts value into a boolean object. 'true' and '1' are converted to true, everything else is false.\n* **csv**: Converts value into an array by splitting on comma's.\n* **list**: Allows for option to be defined multiple times, and each value added to an array\n* **[list|csv],[type]**: Combo type that allows you to create a list or csv and convert each individual value into a type.\n\n```js\nargv.option([\n\t{\n\t\tname: 'option',\n\t\ttype: 'csv,int'\n\t},\n\t{\n\t\tname: 'path',\n\t\tshort: 'p',\n\t\ttype: 'list,path'\n\t}\n]);\n\n// csv and int combo\n$ script --option=123,456.001,789.01\n-> option: [ 123, 456, 789 ]\n\n// list and path combo\n$ script -p /path/to/file1 -p /path/to/file2\n-> option: [ '/path/to/file1', '/path/to/file2' ]\n```\n\nYou can also create your own custom type for special conversions.\n\n```js\nargv.type( 'squared', function( value ) {\n\tvalue = parseFloat( value );\n\treturn value * value;\n});\n\nargv.option({\n\tname: 'square',\n\tshort: 's',\n\ttype: 'squared'\n});\n\n$ script -s 2\n-> 4\n```\n\n\n### Version\n\nDefining the scripts version number will add the version option and print it out when asked.\n\n```js\nargv.version( 'v1.0' );\n\n$ script --version\nv1.0\n\n```\n\n\n### Info\n\nCustom information can be displayed at the top of the help printout using this method\n\n```js\nargv.info( 'Special script info' );\n\n$ script --help\n\nSpecial script info\n\n... Rest of Help Doc ...\n```\n\n\n### Clear\n\nIf you have competing scripts accessing the argv object, you can clear out any previous options that may have been set.\n\n```js\nargv.clear().option( [new options] );\n```\n\n\n### Help\n\nargv injects a default help option initially and on clears. The help() method triggers the help printout.\n\n```js\nargv.help();\n```\n","_attachments":{},"readmeFilename":"README.md"}