Pass the state through reevaluate_whenjobs and run_job.
[whenjobs.git] / tools / whenjobs.ml
index cfef9d6..582f259 100644 (file)
@@ -102,6 +102,7 @@ let rec main () =
     "-e", Arg.Unit (set_mode `Edit), " Edit and upload the script";
     "--edit", Arg.Unit (set_mode `Edit), " Edit and upload the script";
     "--get", Arg.Unit (set_mode `Get), "var Display the variable";
+    "--job-names", Arg.Unit (set_mode `JobNames), " List names of loaded jobs";
     "--jobs", Arg.Unit (set_mode `Jobs), " List running jobs";
     "-l", Arg.Unit (set_mode `List), " List the script";
     "--list", Arg.Unit (set_mode `List), " List the script";
@@ -245,6 +246,10 @@ Options:
     );
     tail arg1
 
+  | Some `JobNames ->
+    unused_error args "--job-names";
+    job_names ()
+
 and edit_file () =
   (* If there is no initial file, create an empty one containing the
    * tutorial.
@@ -447,6 +452,12 @@ and tail serial =
       (Filename.quote job.Whenproto_aux.job_tmpdir) in
   exit (Sys.command cmd)
 
+and job_names () =
+  let client = start_client () in
+  let names = Whenproto_clnt.When.V1.get_job_names client () in
+  stop_client client;
+  Array.iter print_endline names
+
 and unused_error args op =
   if args <> [] then (
     eprintf "whenjobs %s: unused parameters on the command line.\n" op;