Browse Source

Clean up status code

Leo 8 years ago
parent
commit
955feb0b41
1 changed files with 16 additions and 20 deletions
  1. 16 20
      src/state.ml

+ 16 - 20
src/state.ml

@@ -41,24 +41,20 @@ open Core.Std;;
 (* TODO Print whether auto-launch is set or not *)
 (* Display current state *)
 let print_current ~(rc:Rc.t) () =
-  Tmp_file.(init ()
-            |> (fun tmp -> get_accurate_log ~tmp ())
-            |> Exec_cmd.less_launched_num
-            |> Tools.spy1_int_option)
-  |> Option.value_map
-       ~default:"Nothing next"
-       ~f:(fun ( num : int ) ->
-
-            (* XXX Debug *)
-            sprintf "Num: %i" num |> Messages.debug;
-
-            rc#entry ~n:num
-            |> (function
-                 | Some entry -> entry#command
-                 | None -> Messages.warning "Error, should not append, this is a bug";
-                   assert false)
-            |> (fun ( cmd : string ) ->
-                 Messages.debug cmd; (* TODO Use tools.spy1 *)
-                 sprintf "Next: command %i, '%s'" num cmd))
-  |> Messages.ok
+  let log =
+    Tmp_file.init ()
+    |> (fun tmp -> Tmp_file.get_accurate_log ~tmp ())
+  in
+  let next_command =
+    match
+      Exec_cmd.less_launched_num log
+      |> Tools.spy1_int_option
+    with
+    | Some num ->
+      rc#entry ~n:num
+      |> Option.value_exn
+      |> fun entry -> sprintf "Next: command %i, '%s'" num entry#command
+    | None -> "Nothing next"
+  in
+  Messages.ok next_command
 ;;