Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Halliday
committed
Jun 25, 2013
1 parent
1b9f5db
commit a5bf46a
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
This software is released under the MIT license: | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var argv = require('../')(process.argv.slice(2)); | ||
console.dir(argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "minimist", | ||
"version": "0.0.0", | ||
"description": "parse argument options", | ||
"main": "index.js", | ||
"devDependencies": { | ||
"tape": "~1.0.4", | ||
"tap": "~0.4.0" | ||
}, | ||
"scripts": { | ||
"test": "tap test/*.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/substack/minimist.git" | ||
}, | ||
"homepage": "https://github.com/substack/minimist", | ||
"keywords": [ | ||
"argv", | ||
"getopt", | ||
"parser", | ||
"optimist" | ||
], | ||
"author": { | ||
"name": "James Halliday", | ||
"email": "mail@substack.net", | ||
"url": "http://substack.net" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# minimist | ||
|
||
parse argument options | ||
|
||
This module is the guts of optimist's argument parser without all the | ||
fanciful decoration. | ||
|
||
# example | ||
|
||
``` js | ||
var argv = require('minimist')(process.argv.slice(2)); | ||
console.dir(argv); | ||
``` | ||
|
||
``` | ||
$ node example/parse.js -a beep -b boop | ||
{ _: [], a: 'beep', b: 'boop' } | ||
``` | ||
|
||
``` | ||
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz | ||
{ _: [ 'foo', 'bar', 'baz' ], | ||
x: 3, | ||
y: 4, | ||
n: 5, | ||
a: true, | ||
b: true, | ||
c: true, | ||
beep: 'boop' } | ||
``` | ||
|
||
# methods | ||
|
||
``` js | ||
var parseArgs = require('minimist') | ||
``` | ||
|
||
## var argv = parseArgs(args, opts={}) | ||
|
||
Return an argument object `argv` populated with the array arguments from `args`. | ||
|
||
`argv._` contains all the arguments that didn't have an option associated with | ||
them. | ||
|
||
Numeric-looking arguments will be returned as numbers unless `opts.string` or | ||
`opts.boolean` is set for that argument name. | ||
|
||
Any arguments after `'--'` will not be parsed and will end up in `argv._`. | ||
|
||
options can be: | ||
|
||
* `opts.string` - a string or array of strings argument names to always treat as | ||
strings | ||
* `opts.boolean` - a string or array of strings to always treat as booleans | ||
* `opts.alias` - an object mapping string names to strings or arrays of string | ||
argument names to use as aliases | ||
* `opts.default` - an object mapping string argument names to default values | ||
|
||
# install | ||
|
||
With [npm](https://npmjs.org) do: | ||
|
||
``` | ||
npm install minimist | ||
``` | ||
|
||
# license | ||
|
||
MIT |