diff --git a/include/parse_config.ml b/include/parse_config.ml index 0669f39e..5a0b6a98 100644 --- a/include/parse_config.ml +++ b/include/parse_config.ml @@ -120,37 +120,39 @@ let parse s = | Error msg -> Fmt.failwith "config parse error: %s" msg | Ok v -> fold_sections v -let pp_item ppf { key; value } = - let open Fmt in - match String.contains value '"' || String.contains value ' ' with - | false -> pf ppf "%s = %s" key value - | true -> pf ppf "%s = \"%s\"" key value +module Pp_debug = struct + let pp_item ppf { key; value } = + let open Fmt in + match String.contains value '"' || String.contains value ' ' with + | false -> pf ppf "%s = %s" key value + | true -> pf ppf "%s = \"%s\"" key value -let pp_line ppf line = - let open Fmt in - match line with - | Blank -> Fmt.nop ppf () - | Comment s -> pf ppf "#%s" s - | Header s -> pf ppf "[%s]" s - | Item item -> pf ppf "%a" pp_item item + let pp_line ppf line = + let open Fmt in + match line with + | Blank -> Fmt.nop ppf () + | Comment s -> pf ppf "#%s" s + | Header s -> pf ppf "[%s]" s + | Item item -> pf ppf "%a" pp_item item -let _pp_lines ppf raw_line_l = - let open Fmt in - pf ppf "%a" (list ~sep:(any "\n") pp_line) raw_line_l + let _pp_lines ppf raw_line_l = + let open Fmt in + pf ppf "%a" (list ~sep:(any "\n") pp_line) raw_line_l -let pp_section ppf { header; items } = - let open Fmt in - pf ppf "[%s]@\n%a" header (list ~sep:(any "\n") pp_item) items + let pp_section ppf { header; items } = + let open Fmt in + pf ppf "[%s]@\n%a" header (list ~sep:(any "\n") pp_item) items -let pp_config ppf l = - let open Fmt in - pf ppf "%a" (list ~sep:(any "\n") pp_section) l + let pp_config ppf l = + let open Fmt in + pf ppf "%a" (list ~sep:(any "\n") pp_section) l +end let () = let content = read_file "default.config" in (*Fmt.pr "%s" content;*) let config = parse content in (*Fmt.pr "%a@." pp_lines config;*) - Fmt.pr "%a@." pp_config config; + Fmt.pr "%a@." Pp_debug.pp_config config; ()