Skip to content

Commit

Permalink
updated readme and examples with new auto-numberification goodness
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Dec 17, 2010
1 parent 73dc901 commit 8f17014
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
22 changes: 12 additions & 10 deletions README.markdown
Expand Up @@ -27,8 +27,8 @@ xup.js:
$ ./xup.js --rif=55 --xup=9.52
Buy more riffiwobbles

$ ./xup.js --rif 55 --xup 9.52
Buy more riffiwobbles
$ ./xup.js --rif 12 --xup 8.1
Sell the xupptumblers

But wait! There's more! You can do short options:
-------------------------------------------------
Expand Down Expand Up @@ -121,10 +121,7 @@ default_singles.js:
.default('y', 10)
.argv
;

var x = parseInt(argv.x, 10);
var y = parseInt(argv.y, 10);
console.log(x + y);
console.log(argv.x + argv.y);

***

Expand All @@ -137,16 +134,21 @@ default_hash.js:
.default({ x : 10, y : 10 })
.argv
;

var x = parseInt(argv.x, 10);
var y = parseInt(argv.y, 10);
console.log(x + y);
console.log(argv.x + argv.y);

***

$ ./default_hash.js -y 7
17

Notes
=====

Every argument that looks like a number (`!isNaN(Number(arg))`) is converted to
one. This way you can just `net.createConnection(argv.port)` and you can add
numbers out of `argv` with `+` without having that mean concatenation,
which is super frustrating.

Installation
============

Expand Down
4 changes: 1 addition & 3 deletions examples/default_hash.js
Expand Up @@ -5,6 +5,4 @@ var argv = require('optimist')
.argv
;

var x = parseInt(argv.x, 10);
var y = parseInt(argv.y, 10);
console.log(x + y);
console.log(argv.x + argv.y);
6 changes: 1 addition & 5 deletions examples/default_singles.js
@@ -1,11 +1,7 @@
#!/usr/bin/env node

var argv = require('optimist')
.default('x', 10)
.default('y', 10)
.argv
;

var x = parseInt(argv.x, 10);
var y = parseInt(argv.y, 10);
console.log(x + y);
console.log(argv.x + argv.y);

0 comments on commit 8f17014

Please sign in to comment.