diff options
author | John Estabrook <jestabro@vyos.io> | 2022-02-23 14:32:02 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-02-23 14:32:02 -0600 |
commit | 23173c6b5d12e5b7990fafe2b43d40f5cbf1a2a5 (patch) | |
tree | 89ab7ce326551e0103d076e57f3ae6eef6152cdb /src | |
parent | 4d5e3522c14aa22538942e2601be5b6963236452 (diff) | |
download | vyos1x-config-23173c6b5d12e5b7990fafe2b43d40f5cbf1a2a5.tar.gz vyos1x-config-23173c6b5d12e5b7990fafe2b43d40f5cbf1a2a5.zip |
T4235: add utility function get_subtree
Diffstat (limited to 'src')
-rw-r--r-- | src/config_tree.ml | 9 | ||||
-rw-r--r-- | src/config_tree.mli | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/config_tree.ml b/src/config_tree.ml index 6ae7ad2..3e97e80 100644 --- a/src/config_tree.ml +++ b/src/config_tree.ml @@ -101,6 +101,15 @@ let is_tag node path = let data = Vytree.get_data node path in data.tag +let get_subtree ?(with_node=false) node path = + try + let n = Vytree.get node path in + if with_node then + Vytree.make_full default_data "root" [n] + else + Vytree.make_full default_data "root" (Vytree.children_of_node n) + with Vytree.Nonexistent_path -> make "root" + module Renderer = struct (* Rendering configs as set commands *) diff --git a/src/config_tree.mli b/src/config_tree.mli index cf94af7..5375c23 100644 --- a/src/config_tree.mli +++ b/src/config_tree.mli @@ -34,6 +34,8 @@ val set_tag : t -> string list -> bool -> t val is_tag : t -> string list -> bool +val get_subtree : ?with_node:bool -> t -> string list -> t + val render_commands : ?op:command -> t -> string list -> string val render_config : t -> string |