Permalink
Browse files

Added usage docs

  • Loading branch information...
tj committed Jun 23, 2010
1 parent 5a6fa85 commit 0bb2206322a7b26a3da860877bfba03c7698e40c
Showing with 37 additions and 2 deletions.
  1. +2 −2 Makefile
  2. +35 −0 lib/index.js
View
@@ -1,8 +1,8 @@
PREFIX = /usr/local
-install: bin/dox
- cp -f $< $(PREFIX)/bin/dox
+install:
+ cp -f bin/dox $(PREFIX)/bin/dox
cp -fr lib ~/.node_libraries/dox
uninstall:
View
@@ -30,6 +30,19 @@ var title = 'Dont forget to use --title to specify me!';
var jsdoc = true;
+/**
+ * Usage.
+ */
+
+var usage = ''
+ + 'Usage: dox [options] <file ...>\n'
+ + '\n'
+ + 'Options:\n'
+ + ' -t, --title Document title\n'
+ + ' -s, --style Document style, available: ["default"]\n'
+ + ' -h, --help Display help information'
+ + '\n';
+
/**
* Parse the given arguments.
*
@@ -40,10 +53,32 @@ var jsdoc = true;
exports.parse = function(args){
var files = [];
+ // Require an argument
+ function requireArg(){
+ if (args.length) {
+ return args.shift();
+ } else {
+ throw new Error(arg + ' requires an argument.');
+ }
+ }
+
// Parse arguments
while (args.length) {
var arg = args.shift();
switch (arg) {
+ case '-h':
+ case '--help':
+ sys.puts(usage);
+ process.exit(1);
+ break;
+ case '-t':
+ case '--title':
+ title = requireArg();
+ break;
+ case '-s':
+ case '--style':
+ style = requireArg();
+ break;
default:
files.push(arg);
}

0 comments on commit 0bb2206

Please sign in to comment.