Skip to content

Commit

Permalink
boolean examples
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Feb 13, 2011
1 parent 0e380b9 commit dff6d07
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
31 changes: 31 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,37 @@ default_hash.js:
$ ./default_hash.js -y 7
17

And if you really want to get all descriptive about it...
---------------------------------------------------------

boolean_single.js
#!/usr/bin/env node
var argv = require('optimist')
.boolean('v')
.argv
;
console.dir(argv);

***
$ ./boolean_single.js -v foo bar baz
true
[ 'bar', 'baz', 'foo' ]

boolean_double.js

#!/usr/bin/env node
var argv = require('optimist')
.boolean(['x','y','z'])
.argv
;
console.dir([ argv.x, argv.y, argv.z ]);
console.dir(argv._);

***
$ ./boolean_double.js -x -z one two three
[ true, false, true ]
[ 'one', 'two', 'three' ]

Notes
=====

Expand Down
7 changes: 7 additions & 0 deletions examples/boolean_double.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node
var argv = require('optimist')
.boolean(['x','y','z'])
.argv
;
console.dir([ argv.x, argv.y, argv.z ]);
console.dir(argv._);
7 changes: 7 additions & 0 deletions examples/boolean_single.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node
var argv = require('optimist')
.boolean('v')
.argv
;
console.dir(argv.v);
console.dir(argv._);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "optimist",
"version" : "0.1.5",
"version" : "0.1.6",
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.",
"main" : "./index.js",
"repository" : {
Expand Down

0 comments on commit dff6d07

Please sign in to comment.