From 1d49f3b192a574f8356cf0669045732818abc7da Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 3 Dec 2025 14:59:46 -0600 Subject: T8074: minor fixes for vyconf_cli for parity with vyconf_cli_compat --- src/vyconf_cli.ml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/vyconf_cli.ml b/src/vyconf_cli.ml index b2ee630..d65c56b 100644 --- a/src/vyconf_cli.ml +++ b/src/vyconf_cli.ml @@ -38,7 +38,12 @@ let in_cli_config_session () = | None -> false let get_session () = - let pid = Int32.of_int (Unix.getppid()) in + let pid = + try (* set for config session *) + Int32.of_string (Sys.getenv "SESSION_PID") + with Not_found -> + Int32.of_int (Unix.getppid()) + in let user = try Sys.getenv "USER" with Not_found -> "" @@ -85,12 +90,30 @@ let main op path = close_session () |> Lwt.ignore_result in match result with - | Ok s -> let%lwt () = Lwt_io.write Lwt_io.stdout s in Lwt.return 0 - | Error e -> let%lwt () = Lwt_io.write Lwt_io.stderr (Printf.sprintf "%s\n" e) in Lwt.return 1 + | Ok s -> + begin + match s with + | "" -> Lwt.return 0 + | _ -> + let%lwt () = + Lwt_io.write Lwt_io.stdout (Printf.sprintf "%s\n" s) in Lwt.return 0 + end + | Error e -> + begin + match e with + | "" -> Lwt.return 1 + | _ -> + let%lwt () = + Lwt_io.write Lwt_io.stderr (Printf.sprintf "%s\n" e) in Lwt.return 1 + end let () = let path_list = Array.to_list (Array.sub Sys.argv 1 (Array.length Sys.argv - 1)) in let op_str = FilePath.basename Sys.argv.(0) in let op = op_of_string op_str in - let result = Lwt_main.run (main op path_list) in exit result + match op, path_list with + | OpSet, [] | OpDelete, [] -> + let () = print_endline "Must specify config path" in exit 1 + | _, _ -> + let result = Lwt_main.run (main op path_list) in exit result -- cgit v1.2.3 From 4028c234ce9e42ef76bcc5243fb0cf75aff09f9b Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Fri, 5 Dec 2025 13:00:37 -0600 Subject: T8074: drop vyconf_cli options that are handled by vyconf_cli_compat --- src/vyconf_cli.ml | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/vyconf_cli.ml b/src/vyconf_cli.ml index d65c56b..8563572 100644 --- a/src/vyconf_cli.ml +++ b/src/vyconf_cli.ml @@ -5,16 +5,12 @@ type op_t = | OpSet | OpDelete | OpDiscard - | OpShowConfig - | OpSessionChanged let op_of_string s = match s with | "vy_set" -> OpSet | "vy_delete" -> OpDelete | "vy_discard" -> OpDiscard - | "vy_show" -> OpShowConfig - | "vy_session_changed" -> OpSessionChanged | _ -> failwith (Printf.sprintf "Unknown operation %s" s) let config_format_of_string s = @@ -80,8 +76,6 @@ let main op path = | OpSet -> set c path | OpDelete -> delete c path | OpDiscard -> discard c - | OpShowConfig -> show_config c path - | OpSessionChanged -> session_changed c end | Error e -> Error e |> Lwt.return in -- cgit v1.2.3