let cli_parse ?argv extra_specs conf =
let specs =
Hashtbl.fold
(fun name metadata lst ->
let cli_lst =
match metadata.cli conf with
| (key, spec, doc) :: tl ->
(key, spec, doc ^
(Printf.sprintf " (default: %s)"
(metadata.get_print conf)))
:: tl
| [] -> []
in
cli_lst @ lst)
metaconf
[]
in
let all_specs =
Arg.align
([
"-conf",
Arg.String (file_parse conf),
"fn Read configuration file."
]
@ (List.sort Pervasives.compare specs)
@ extra_specs)
in
let arg_parse =
match argv with
| Some arr ->
Arg.parse_argv ~current:(ref 0) arr
| None ->
Arg.parse
in
arg_parse
all_specs
(fun x -> raise (Arg.Bad ("Unexpected argument: " ^ x)))
("usage: " ^ Sys.argv.(0) ^ " options*")