summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/adapter/vy_delete.ml14
-rw-r--r--src/adapter/vy_set.ml36
2 files changed, 19 insertions, 31 deletions
diff --git a/src/adapter/vy_delete.ml b/src/adapter/vy_delete.ml
index 652fdad..304e74b 100644
--- a/src/adapter/vy_delete.ml
+++ b/src/adapter/vy_delete.ml
@@ -1,16 +1,6 @@
-let path_opt = ref []
-
-let usage = "Usage: " ^ Sys.argv.(0) ^ " [options]"
-
-let read_path p =
- path_opt := p::!path_opt
-
-let speclist = [
- ]
-
let () =
- let () = Arg.parse speclist read_path usage in
- let path_list = List.rev !path_opt in
+ let path_list = Array.to_list (Array.sub Sys.argv 1 (Array.length Sys.argv - 1))
+ in
let () =
if List.length path_list = 0 then
(Printf.printf "no path specified\n"; exit 1)
diff --git a/src/adapter/vy_set.ml b/src/adapter/vy_set.ml
index 1fb29aa..b631de0 100644
--- a/src/adapter/vy_set.ml
+++ b/src/adapter/vy_set.ml
@@ -1,18 +1,4 @@
-let legacy = ref false
-let no_set = ref false
let valid = ref false
-let output = ref ""
-let path_opt = ref []
-
-let usage = "Usage: " ^ Sys.argv.(0) ^ " [options]"
-
-let read_path p =
- path_opt := p::!path_opt
-
-let speclist = [
- ("--legacy", Arg.Unit (fun _ -> legacy := true), "Use legacy validation");
- ("--no-set", Arg.Unit (fun _ -> no_set := true), "Do not set path");
- ]
let format_out l =
let fl = List.filter (fun s -> (String.length s) > 0) l in
@@ -27,14 +13,26 @@ let valid_err v =
Option.value v ~default:""
let () =
- let () = Arg.parse speclist read_path usage in
- let path_list = List.rev !path_opt in
+ let path_list = Array.to_list (Array.sub Sys.argv 1 (Array.length Sys.argv - 1))
+ in
let () =
if List.length path_list = 0 then
(Printf.printf "no path specified\n"; exit 1)
in
+ let legacy =
+ try
+ let _ = Sys.getenv "LEGACY_VALIDATE" in
+ true
+ with Not_found -> false
+ in
+ let no_set =
+ try
+ let _ = Sys.getenv "LEGACY_NO_SET" in
+ true
+ with Not_found -> false
+ in
let handle =
- if !legacy || not !no_set then
+ if legacy || not no_set then
let h = Vyos1x_adapter.cstore_handle_init () in
if not (Vyos1x_adapter.cstore_in_config_session_handle h) then
(Vyos1x_adapter.cstore_handle_free h;
@@ -43,7 +41,7 @@ let () =
else None
in
let valid =
- if not !legacy then
+ if not legacy then
Vyos1x_adapter.vyconf_validate_path path_list
else
begin
@@ -58,7 +56,7 @@ let () =
end
in
let res =
- if not !no_set && (is_valid valid) then
+ if not no_set && (is_valid valid) then
match handle with
| Some h ->
Vyos1x_adapter.cstore_set_path h path_list