Use Arg to parse arguments
This commit is contained in:
parent
679402b10f
commit
6c2875bb6b
1 changed files with 18 additions and 5 deletions
23
bin/main.ml
23
bin/main.ml
|
|
@ -1,11 +1,24 @@
|
||||||
|
let usage_msg = "inspector -log <logfile> -db <dbfile>"
|
||||||
|
let logfile = ref ""
|
||||||
|
let dbfile = ref ""
|
||||||
|
|
||||||
|
let speclist =
|
||||||
|
[
|
||||||
|
("-log", Arg.Set_string logfile, "Set log filename");
|
||||||
|
("-db", Arg.Set_string dbfile, "Set XAPI db file");
|
||||||
|
]
|
||||||
|
|
||||||
|
let ignore_anon arg = print_endline @@ arg ^ " is ignored"
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
let open Inspector in
|
Arg.parse speclist ignore_anon usage_msg;
|
||||||
if Array.length Sys.argv <> 2 then (
|
if !logfile = "" then (
|
||||||
Printf.eprintf "Usage: %s <logfile>\n" (Filename.basename Sys.argv.(0));
|
Printf.eprintf "You must specify a log file using -log\n";
|
||||||
exit 1);
|
exit 1);
|
||||||
|
|
||||||
let s = State.create Sys.argv.(1) in
|
let open Inspector in
|
||||||
|
let s = State.create !logfile in
|
||||||
|
Printf.printf "dbfile is currently ignored\n";
|
||||||
Printf.printf "Loaded %d lines\n" (State.size s);
|
Printf.printf "Loaded %d lines\n" (State.size s);
|
||||||
Repl.help ();
|
Repl.help ();
|
||||||
|
|
||||||
Repl.loop s
|
Repl.loop s
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue