[OCaml] Mobile-friendly clone of cgit.
feat add --git-project-root CLI option
Override the configured git_project_root at runtime, e.g.: ogit --git-project-root /srv/git
Changed files
bin/main.ml
@@ -1,3 +1,15 @@
1
1
(* -*- mode: tuareg; -*- *)
2
2
3
Removed:
let () = Ogit.Main.run ()
3
Added:
let usage = "Usage: ogit [--git-project-root <path>]"
4
Added:
5
Added:
let () =
6
Added:
let git_project_root = ref None in
7
Added:
let speclist =
8
Added:
[
9
Added:
( "--git-project-root",
10
Added:
Arg.String (fun path -> git_project_root := Some path),
11
Added:
"<path> Root directory containing Git repositories" );
12
Added:
]
13
Added:
in
14
Added:
Arg.parse speclist (fun _ -> ()) usage;
15
Added:
Ogit.Main.run ?git_project_root:!git_project_root ()
lib/main.ml
@@ -5,7 +5,17 @@
5
5
@@ Dream.logger
6
6
@@ Dream.router (Handlers.routes config)
7
7
8
Removed:
let run () =
9
Removed:
match Config.load () with
10
Removed:
| Ok config -> run_with_config config
11
Removed:
| Error error -> failwith (Config.load_error_to_string error)
8
Added:
let run ?git_project_root () =
9
Added:
let config =
10
Added:
match Config.load () with
11
Added:
| Ok config -> config
12
Added:
| Error error ->
13
Added:
if Option.is_some git_project_root then Config.default
14
Added:
else failwith (Config.load_error_to_string error)
15
Added:
in
16
Added:
let config =
17
Added:
match git_project_root with
18
Added:
| Some path -> { config with git_project_root = path }
19
Added:
| None -> config
20
Added:
in
21
Added:
run_with_config config