diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-12-03 14:59:46 -0600 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-12-05 12:59:10 -0600 |
| commit | 1d49f3b192a574f8356cf0669045732818abc7da (patch) | |
| tree | 50742244f87bd14e7c3aef192ff508a3244542c8 /src | |
| parent | b4acb65d767c4af1f1df2b252ea9030735c08342 (diff) | |
| download | vyconf-1d49f3b192a574f8356cf0669045732818abc7da.tar.gz vyconf-1d49f3b192a574f8356cf0669045732818abc7da.zip | |
T8074: minor fixes for vyconf_cli for parity with vyconf_cli_compat
Diffstat (limited to 'src')
| -rw-r--r-- | src/vyconf_cli.ml | 31 |
1 files changed, 27 insertions, 4 deletions
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 |
