diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-05-21 23:39:21 +0700 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-05-21 23:39:21 +0700 |
commit | c53fbb4e60896692485a95ce4fd2a6aeb58d66a7 (patch) | |
tree | 5513fb5278266e24d80ecec6ee37b77a1774d567 /src | |
parent | dc4bedee63c2c4d8c1dbd3c6aa9a12f4e072681b (diff) | |
download | vyconf-c53fbb4e60896692485a95ce4fd2a6aeb58d66a7.tar.gz vyconf-c53fbb4e60896692485a95ce4fd2a6aeb58d66a7.zip |
Get the show_config operation to work correctly.
Diffstat (limited to 'src')
-rw-r--r-- | src/session.ml | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/session.ml b/src/session.ml index a502629..832bfe6 100644 --- a/src/session.ml +++ b/src/session.ml @@ -108,10 +108,14 @@ let exists w s path = let show_config w s path fmt = let open Vyconf_types in - if not (Vytree.exists s.proposed_config path) then + if (path <> []) && not (Vytree.exists s.proposed_config path) then raise (Session_error ("Path does not exist")) else - let node = Vytree.get s.proposed_config path in + let node = s.proposed_config in match fmt with - | Curly -> CT.render node - | Json -> CT.to_yojson node |> Yojson.Safe.pretty_to_string + | Curly -> CT.render_at_level node path + | Json -> + let node = + (match path with [] -> s.proposed_config | + _ as ps -> Vytree.get s.proposed_config ps) in + CT.to_yojson node |> Yojson.Safe.pretty_to_string |