Yaron Minsky avatar Yaron Minsky committed e13f54f

slight cleanups, improved spinner

Comments (0)

Files changed (4)

     (fun username () -> setup_conn username (fun username conn ->
        Rpc.Rpc.dispatch_exn Protocol.stop conn username))
 
-let spinner =
-  let states = [| "|" ; "/"; "-"; "\\" |] in
-  let pos = ref 0 in
-  (fun () ->
-     pos := (!pos + 1) % Array.length states;
-     states.(!pos)
-  )
-
 let span_string span =
   let { Time.Span.Parts.
         sign = _
          >>= fun cstring ->
          let stop = force on_term_signal in
          Clock.every' (sec 1.) ~stop (fun () ->
+             let spinner = force spinner in
              match Robust_connection.get rconn with
              | None -> printf "%sWaiting for reconnection\n" cstring; return ()
              | Some conn ->
 let clear_string =
   lazy (shell_run "clear" [])
 
+let spinner = lazy (
+  let states = [| "|" ; "/"; "-"; "\\" |] in
+  let pos = ref 0 in
+  every (sec 1.0) (fun () -> 
+      pos := (!pos + 1) % Array.length states);
+  fun () -> states.(!pos)
+)
+
 let clear_screen () =
   force clear_string
   >>| fun clear_string ->

client_common.mli

   with sexp
 end
 
+val spinner : (unit -> string) Lazy.t
 val load_config : unit -> Config.t Deferred.t
 val get_username : unit -> Username.t Deferred.t
 
   let alert_throttle =
     unstage (throttle (sec 30.) ~if_not_run:(fun () -> Deferred.unit))
   in
+  let spinner = Lazy.force spinner in
   upon stop (fun () -> Pipe.close_read r);
   Async_shell.run_full "which" [Sys.argv.(0)]
   >>= fun my_path ->
   Pipe.iter r ~f:(fun violations ->
       clear_screen ()
       >>= fun () ->
+      print_endline (spinner ());
       Full_violation.print_list violations;
       Deferred.List.iter violations
         ~f:(fun {Full_violation. rule;exceeded_by;status=_;reportable} ->
                        (Time.Span.to_string exceeded_by))
                 )))
 
-(*
-let rec monitor_violations_loop ~retry_after user conn ~stop =
-  try_with (fun () -> monitor_violations user conn ~stop)
-  >>= function
-  | Error _ ->
-    printf "Connection failed.  Retrying in %s.\n" (Time.Span.to_string retry_after);
-    after retry_after
-    >>= fun () ->
-    monitor_violations_loop ~retry_after user conn ~stop
-  | Ok () -> return ()
-*)
-
 let monitor_violations =
   Command.async_basic
     ~summary:"Monitor for violations"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.