summaryrefslogtreecommitdiff
path: root/src/vyconfd.ml
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-12-17 11:54:20 -0600
committerJohn Estabrook <jestabro@vyos.io>2025-12-17 21:29:58 -0600
commitf58bfaa3487ef821466e35fbd2bb073732e889dd (patch)
treec1c340dc190d2595cc1e1ec8447f163ce56610b2 /src/vyconfd.ml
parent28b6ac04aaef995656eaabb2c9a279a79e657687 (diff)
downloadvyconf-f58bfaa3487ef821466e35fbd2bb073732e889dd.tar.gz
vyconf-f58bfaa3487ef821466e35fbd2bb073732e889dd.zip
T8061: add get_completion_env request
Return help strings and values in the form used by bash completion.
Diffstat (limited to 'src/vyconfd.ml')
-rw-r--r--src/vyconfd.ml12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/vyconfd.ml b/src/vyconfd.ml
index 96c2e42..d34deab 100644
--- a/src/vyconfd.ml
+++ b/src/vyconfd.ml
@@ -433,6 +433,17 @@ let get_path_type world token (req: request_get_path_type) =
with Session.Session_error msg ->
{response_tmpl with status=Fail; error=(Some msg)}
+let get_completion_env world token (req: request_get_completion_env) =
+ let s = find_session token in
+ try
+ let node_type =
+ Session.get_completion_env
+ ~legacy_format:req.legacy_format world s req.path
+ in
+ {response_tmpl with output=(Some node_type)}
+ with Session.Session_error msg ->
+ {response_tmpl with status=Fail; error=(Some msg)}
+
let send_response oc resp =
let enc = Pbrt.Encoder.create () in
let%lwt () = encode_pb_response resp enc |> return in
@@ -492,6 +503,7 @@ let rec handle_connection world ic oc () =
| Some t, Config_unsaved r -> config_unsaved world t r
| Some t, Reference_path_exists r -> reference_path_exists world t r
| Some t, Get_path_type r -> get_path_type world t r
+ | Some t, Get_completion_env r -> get_completion_env world t r
| _ -> failwith "Unimplemented"
) |> Lwt.return
end