diff options
| author | John Estabrook <jestabro@vyos.io> | 2024-10-24 11:04:39 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2024-10-24 11:04:39 -0500 |
| commit | bd64f4508d72d1b2f0c613b5012ad6dc9507f3c6 (patch) | |
| tree | b2c02c511b6b80b0995a9dd64adc77922d807461 /src/reference_tree.ml | |
| parent | 22478789c282dc379e7d7ce1c910a9a301f7b49b (diff) | |
| download | vyos1x-config-bd64f4508d72d1b2f0c613b5012ad6dc9507f3c6.tar.gz vyos1x-config-bd64f4508d72d1b2f0c613b5012ad6dc9507f3c6.zip | |
T6718: add function refpath: config path -> reference_tree path
Diffstat (limited to 'src/reference_tree.ml')
| -rw-r--r-- | src/reference_tree.ml | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml index e920209..353a152 100644 --- a/src/reference_tree.ml +++ b/src/reference_tree.ml @@ -340,6 +340,17 @@ let get_completion_data reftree path = (data.node_type, data.multi, data.help) in List.map aux (Vytree.children_of_node @@ Vytree.get reftree path) +(* Convert from config path to reference tree path *) +let refpath reftree path = + let rec aux acc p = + match acc, p with + | [], h :: tl -> aux (acc @ [h]) tl + | _, [h] -> if is_tag reftree acc then acc else acc @ [h] + | _, h :: h' :: tl -> if is_tag reftree acc then aux (acc @ [h']) tl + else aux (acc @ [h]) ([h'] @ tl) + | _, [] -> acc + in aux [] path + module JSONRenderer = struct let render_data data = |
