From c53fbb4e60896692485a95ce4fd2a6aeb58d66a7 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 21 May 2018 23:39:21 +0700 Subject: Get the show_config operation to work correctly. --- src/session.ml | 12 ++++++++---- 1 file 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 -- cgit v1.2.3