Browse Source

Allow run subcommand to take multiple ids

 + Instead of
```
oclaunch run 3
oclaunch run 6
oclaunch run 1
oclaunch run 9
```
one would enter
```
oclaunch run 3 6 1 9
```
Leo 9 years ago
parent
commit
6ed939ea36
2 changed files with 9 additions and 4 deletions
  1. 1 0
      CHANGELOG.md
  2. 8 4
      src/command_def.ml

+ 1 - 0
CHANGELOG.md

@@ -62,6 +62,7 @@ This version introduce major changes in the tmp and rc file.
    directly in the program, and using Textutils and Re2 library instead.
  + Display debugging information before each message. Flush stdout on each
    message.
+ + Some subcommand, such as `run`, take list of ids instead of only one.
  + Adapt code a bit for OCaml 4.03.
  + TODO XXX Add basic signal handling (`--signals`), to relaunch when doing
    ctrl-C. See issue #14 for known problems.

+ 8 - 4
src/command_def.ml

@@ -278,15 +278,19 @@ let licence =
 (* Run nth command, default use *)
 let default =
   basic
-    ~summary:"Run the [COMMAND_NUMBER]th command"
+    ~summary:"Run the [COMMAND_NUMBER]th command(s)"
     Spec.(
       empty
       +> shared_params
-      +> anon (maybe ("command_number" %: int))
+      +> anon (maybe (sequence ("command_number" %: int)))
     )
-    (fun { rc } n () ->
+    (fun { rc } n_list () ->
        let rc = Lazy.force rc in
-       Default.run ~rc n)
+       (* XXX Manually dealing with the None case to make sure we are running
+        * next command if nothing is given *)
+       match n_list with None -> Default.run ~rc None
+       | Some n_list ->
+           List.iter n_list ~f:(fun n -> Default.run ~rc (Some n)))
 
 let run ~version ~build_info () =
   (* Store begin time *)