Permalink
Browse files

boolean examples

  • Loading branch information...
substack committed Feb 13, 2011
1 parent 0e380b9 commit dff6d078d97f8ac503c7d18dcc7b7a8c364c2883
Showing with 46 additions and 1 deletion.
  1. +31 −0 README.markdown
  2. +7 −0 examples/boolean_double.js
  3. +7 −0 examples/boolean_single.js
  4. +1 −1 package.json
View
@@ -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
=====
@@ -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._);
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+var argv = require('optimist')
+ .boolean('v')
+ .argv
+;
+console.dir(argv.v);
+console.dir(argv._);
View
@@ -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" : {

0 comments on commit dff6d07

Please sign in to comment.