X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=tools%2Fwhenjobs.ml;h=f8a0659b323239203d55ac3c393d2185d6d117dc;hp=dade6c2b0936c5091fd4a67d543682f80d2c0669;hb=2701d3a832514ee94d110dfbd4f46f2ab6d9637e;hpb=61cad7bbaf63389b520b695eefdd735bc11a8aa6 diff --git a/tools/whenjobs.ml b/tools/whenjobs.ml index dade6c2..f8a0659 100644 --- a/tools/whenjobs.ml +++ b/tools/whenjobs.ml @@ -87,7 +87,7 @@ let rec main () = "--list", Arg.Unit (set_mode `List), " List the script"; "--lib", Arg.Set_string libdir, "dir Specify directory that contains pa_when.cmo"; "--set", Arg.Unit (set_mode `Set), " Set the variable"; - "--type", Arg.Set_string typ, "bool|int|float|string Set the variable type"; + "--type", Arg.Set_string typ, "bool|int|float|string|unit Set the variable type"; "--upload", Arg.Unit (set_mode `Upload), " Upload the script"; "--variables", Arg.Unit (set_mode `Variables), " Display all variables and values"; "-V", Arg.Unit display_version, " Display version number and exit"; @@ -130,6 +130,7 @@ Options: | "string" -> `String | "int" -> `Int | "float"|"double" -> `Float + | "unit" -> `Unit | t -> eprintf "whenjobs: --type: unknown type (%s)\n" t; exit 1 in @@ -293,10 +294,22 @@ and set_variable name value typ = with Failure _ -> eprintf "whenjobs: variable is not a floating point number\n"; exit 1 - ) in + ) + | `Unit -> + if value <> "" then ( + eprintf "whenjobs: unit variables must be empty strings\n"; + exit 1 + ); + `unit_t in let client = start_client () in - Whenproto_clnt.When.V1.set_variable client (name, value); + (match Whenproto_clnt.When.V1.set_variable client (name, value) with + | `ok -> () + | `error msg -> + eprintf "whenjobs: set: %s\n" msg; + suggest_check_server_logs (); + exit 1 + ); stop_client client and get_variable name = @@ -319,7 +332,15 @@ and daemon_start () = assert false and daemon_stop () = - assert false + let client = start_client () in + (match Whenproto_clnt.When.V1.exit_daemon client () with + | `ok -> () + | `error msg -> + eprintf "whenjobs: daemon-stop: %s\n" msg; + suggest_check_server_logs (); + exit 1 + ); + stop_client client and daemon_restart () = assert false @@ -370,6 +391,7 @@ and stop_client client = Rpc_client.shut_down client and string_of_variable = function + | `unit_t -> "" | `bool_t b -> string_of_bool b | `string_t s -> s | `int_t i -> i (* passed on the wire as a string *)