"use strict";

var express = require("express");
var http = require("http");
var argv = require('minimist')(process.argv.slice(2), {
    alias: {
        p: "port",
        b: "base"
    }
});

var app = express();

var tmpshare = require("./index")({
    dir: argv._[0]
});

if (argv.base) {
    app.use(argv.base, tmpshare);
} else {
    app.use(tmpshare);
}

http.createServer(app).listen(argv.port || 3000, function(err) {
    if (err) throw err;
    var addr = this.address();
    console.log("Listening on http://%s:%d", addr.address, addr.port);
});

@@ -38,24 +38,52 @@
 %22express%22);%0A
+var path = require(%22path%22);%0A
 var http = r
@@ -186,16 +186,35 @@
 %22port%22,%0A
+        h: %22help%22,%0A
         
@@ -230,24 +230,260 @@
 %0A    %7D%0A%7D);%0A%0A
+var dir = argv._%5B0%5D;%0A%0Afunction help() %7B%0A    console.log(%22usage: %22 + path.basename(__filename) + %22 %5B--port=3000%5D %5B--base=/%5D %3Cdir%3E%22);%0A%7D%0A%0Aif (argv.help) %7B%0A    help();%0A    process.exit(0);%0A%7D%0A%0Aif (!dir) %7B%0A    help();%0A    process.exit(1);%0A%7D%0A%0A
 var app = ex
@@ -531,28 +531,16 @@
 %22)(%7B
-%0A    dir: argv._%5B0%5D%0A
+dir: dir
 %7D);%0A

add --help