|
@@ -1,5 +1,5 @@
|
|
|
(******************************************************************************)
|
|
|
-(* Copyright © Joly Clément, 2014-2015 *)
|
|
|
+(* Copyright © Joly Clément, 2014-2016 *)
|
|
|
(* *)
|
|
|
(* leowzukw@oclaunch.eu.org *)
|
|
|
(* *)
|
|
@@ -39,6 +39,37 @@ open Core.Std;;
|
|
|
(* The module containing the step run when the program is
|
|
|
* used without argument or with run command *)
|
|
|
|
|
|
+(* When there is nothing in rc file *)
|
|
|
+let nothing_in_rc () =
|
|
|
+ Messages.ok "There is nothing in your RC file!";
|
|
|
+ Messages.tips "You can add entries with 'edit' or 'add' subcommand.";
|
|
|
+;;
|
|
|
+
|
|
|
+(* If no command was found, all has been launched *)
|
|
|
+let no_cmd_found () =
|
|
|
+ Messages.ok "All has been launched!";
|
|
|
+ Messages.tips "You can reset with 'reset-all' subcommand";
|
|
|
+;;
|
|
|
+
|
|
|
+(* Run given (num) item *)
|
|
|
+let run_item ~rc num =
|
|
|
+ rc#entry ~n:num
|
|
|
+ |> function
|
|
|
+ | None -> Messages.warning "Your number is out of bound"
|
|
|
+ | Some entry ->
|
|
|
+ let cmd_to_exec = entry#command in
|
|
|
+ Exec_cmd.execute cmd_to_exec;
|
|
|
+;;
|
|
|
+
|
|
|
+(* Execute each item (one after the other) in config file *)
|
|
|
+let exec_each ~tmp =
|
|
|
+ Exec_cmd.what_next ~tmp
|
|
|
+ |> function
|
|
|
+ | Exec_cmd.Empty -> nothing_in_rc ()
|
|
|
+ | Finish -> no_cmd_found ()
|
|
|
+ | A cmd_to_exec -> Exec_cmd.execute cmd_to_exec
|
|
|
+;;
|
|
|
+
|
|
|
(* cmd_number is the number of the command the user wants
|
|
|
* to execute *)
|
|
|
let run ~(rc:Rc.t) cmd_number =
|
|
@@ -51,28 +82,6 @@ let run ~(rc:Rc.t) cmd_number =
|
|
|
|
|
|
let tmp = Tmp_file.init () in
|
|
|
match cmd_number with
|
|
|
- | None -> begin
|
|
|
- (* Execute each item (one by one) in config file *)
|
|
|
- let open Exec_cmd in
|
|
|
- what_next ~tmp
|
|
|
- |> function
|
|
|
- | Empty -> (* Nothing in RC file *)
|
|
|
- Messages.ok "There is nothing in your RC file!";
|
|
|
- Messages.tips "You can add entries with 'edit' or 'add' subcommand.";
|
|
|
- Lock.remove ()
|
|
|
- | Finish -> (* If no command was found, all has been launched *)
|
|
|
- Messages.ok "All has been launched!";
|
|
|
- Messages.tips "You can reset with 'reset-all' subcommand";
|
|
|
- Lock.remove ()
|
|
|
- | A cmd_to_exec -> Exec_cmd.execute cmd_to_exec;
|
|
|
- end
|
|
|
- | Some num -> begin
|
|
|
- (* Run given (num) item *)
|
|
|
- rc#entry ~n:num
|
|
|
- |> function
|
|
|
- | None -> Messages.warning "Your number is out of bound"
|
|
|
- | Some entry ->
|
|
|
- let cmd_to_exec = entry#command in
|
|
|
- Exec_cmd.execute cmd_to_exec;
|
|
|
- end
|
|
|
+ | None -> exec_each ~tmp; Lock.remove ()
|
|
|
+ | Some num -> run_item ~rc num
|
|
|
;;
|