Permalink
Browse files

Use optimist as cli option parser

  • Loading branch information...
1 parent a2b7810 commit 9c5e2e1a32603ada6bfff00af1bb31406ba574c7 @5long committed Aug 24, 2011
Showing with 12 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −0 package.json
  3. +10 −1 src/bin/cli.js
View
1 .gitignore
@@ -1 +1,2 @@
*.swp
+/node_modules
View
1 package.json
@@ -3,6 +3,7 @@
}
, "bin": {"reut": "./src/bin/cli.js"}
, "description": "REimplemented Unit Test for node.js"
+, "dependencies": { "optimist": "~0.2"}
, "engines": {"node": ">=0.1.103"}
, "homepage": "http://github.com/5long/reut"
, "keywords": ["test", "testing", "unit test", "TDD"]
View
11 src/bin/cli.js
@@ -3,9 +3,11 @@ var runner = require("../runner")
, util = require("../util")
, async = util.async
, path = require("path")
+ , optimist = require("optimist")
function main() {
- var files = util.makeArray(process.argv, 2)
+ var args = extractArgs()
+ , files = args._.slice()
, cwd = process.cwd()
async.map(files, function(file) {
@@ -33,4 +35,11 @@ function hasFailed(results) {
})
}
+function extractArgs() {
+ return optimist
+ .demand(1)
+ .usage("Usage: $0 [--] <test file...>")
+ .argv
+}
+
main()

0 comments on commit 9c5e2e1

Please sign in to comment.