Skip to content

Commit 337c2b8

Browse files
Use docopt and accept options --port and --cache-dir
1 parent bcd6d04 commit 337c2b8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Main.hx

+11
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ class Main {
135135

136136
static function main()
137137
{
138+
var usage = "
139+
Usage:
140+
git-cache-http-server.js [options]
141+
142+
Options:
143+
--port <port>, -p <port> Bind to port [default: 8080]
144+
--cache-dir <path>, -c <path> Location of the git cache [default: /var/cache/git]
145+
";
146+
var options = js.npm.Docopt.docopt(usage, { argv : Sys.args().slice(2) });
147+
listenPort = Std.parseInt(options["--port"]);
148+
cacheDir = options["--cache-dir"];
138149
Http.createServer(handleRequest).listen(listenPort);
139150
}
140151
}

src/js/npm/Docopt.hx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package js.npm;
2+
3+
@:jsRequire("docopt")
4+
extern class Docopt {
5+
static function docopt(doc:String, args : { ?argv:Array<String>, ?help:Bool, ?version:String, ?options_first:Bool, ?exit:Bool }):haxe.DynamicAccess<Dynamic>;
6+
}
7+

0 commit comments

Comments
 (0)