Skip to content

Commit

Permalink
Output the version if asked.
Browse files Browse the repository at this point in the history
  • Loading branch information
philjackson committed Aug 10, 2011
1 parent f94ac29 commit 1845d37
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/twerp.coffee
@@ -1,10 +1,16 @@
# grab the args we want

fs = require "fs"
util = require "util"
runners = require "../lib/runner/"
sys = require "sys"
OptionParser = require( "../vendor/parseopt" ).OptionParser

getVersion = ( ) ->
package = JSON.parse( fs.readFileSync "package.json", "utf8" )

return package.version

parser = new OptionParser
parser.add "--exit-on-failure",
type: "flag"
Expand Down Expand Up @@ -32,6 +38,9 @@ parser.add "--runner",
values: name for name, runner of runners
help: "Which runner to use (where a runner controls output)."

parser.add "--version",
type: "option"

try
options = parser.parse( )
catch e
Expand All @@ -42,6 +51,10 @@ catch e
name = options.options.runner
runner = new runners[ name ] options.options, options.arguments

if options.options.version
console.log getVersion()
process.exit 0

try
runner.run ( ) ->
if runner.total_failed > 0
Expand Down

0 comments on commit 1845d37

Please sign in to comment.