Permalink
Browse files

Added version commandline option.

  • Loading branch information...
1 parent d281f0f commit 48d5c9da6745d5d7f3c6187223ac4606e24f3f88 @meowgorithm committed May 24, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 bin/cakewalk
View
@@ -1,21 +1,32 @@
#!/usr/bin/env node
+var fs = require('fs');
var optimist = require('optimist');
var colors = require('colors');
var Cakewalker = require('../lib/cakewalk.js').Cakewalker;
var argv = optimist
.wrap(76)
.usage('Usage $0 [path]')
- .alias('h', 'help')
.describe('h', 'Show this help message and exit')
+ .alias('h', 'help')
+ .describe('v', 'Print version information and exit')
+ .alias('v', 'version')
.argv;
+// Print help and exit
if(argv.h) {
console.log(optimist.help());
process.exit();
}
+// Print version number and exit
+if(argv.v) {
+ var packageJSON = fs.readFileSync(__dirname + '/../package.json', 'utf8');
+ console.log(JSON.parse(packageJSON).version);
+ process.exit();
+}
+
directory = argv._[0] || '.';
console.log('_.:*:._.:* Cakewalk *:._.:*:._'.rainbow);

0 comments on commit 48d5c9d

Please sign in to comment.