blob: a5079c346a1be8893917d7a951dec2d419aa875a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
let name = "configuration"
let description = "Load the configuration file and report errors"
let printer = ref (fun formatter _ -> Format.pp_print_nothing formatter ())
let speclist () =
[
( "--tree",
Arg.Unit
(fun () ->
printer :=
fun formater conf ->
Configuration.Graph_tree.pp formater (Configuration.Ast.tree conf)),
"Print the dependency tree between root contents" );
]
type t = (Configuration.Ast.setting, Configuration.Read_conf.error) result
let pp : Format.formatter -> t -> unit =
Format.pp_print_result ~error:Configuration.Read_conf.pp_error
~ok:(fun formater conf -> !printer formater conf)
let exec : string list -> t =
fun _ ->
let stdin = In_channel.input_all stdin in
let ( let+ ) opt cont = Result.map cont opt in
let+ configuration = Configuration.Read_conf.read_string_conf stdin in
configuration
|