Skip to content

Commit

Permalink
Watch mode: display red/green status in colors
Browse files Browse the repository at this point in the history
When the screen is crowded, it can be a bit tricky to determine if that
last command succeeded or not.

This displays "Success" in green and "Had errors" in red, making this a
bit faster to understand.

Signed-off-by: Etienne Millon <[email protected]>
  • Loading branch information
emillon committed Mar 19, 2019
1 parent c45656d commit 0778c40
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ unreleased
different preprocessing specifications. This warning can now be disabled with
`allow_approx_merlin` (#1947, fix #1946, @rgrinberg)

- Watch mode: display "Success" in green and "Had errors" in red (#1956,
@emillon)

1.8.2 (10/03/2019)
------------------

Expand Down
4 changes: 4 additions & 0 deletions src/colors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ let setup_err_formatter_colors () =

let output_filename : styles = [Bold; Fg Green]

let command_success : styles = [Bold; Fg Green]

let command_error : styles = [Bold; Fg Red]

module Render = Pp.Renderer.Make(struct
type t = Style.t

Expand Down
4 changes: 4 additions & 0 deletions src/colors.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type styles

val output_filename : styles

val command_success : styles

val command_error : styles

val apply_string : styles -> string -> string

module Style : sig
Expand Down
4 changes: 2 additions & 2 deletions src/scheduler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,11 @@ let poll ?log ?config ~once ~finally () =
finally ();
match res with
| Ok () ->
wait "Success" |> after_wait
wait (Colors.apply_string Colors.command_success "Success") |> after_wait
| Error Got_signal ->
(Already_reported, None)
| Error Never ->
wait "Had errors" |> after_wait
wait (Colors.apply_string Colors.command_error "Had errors") |> after_wait
| Error Files_changed ->
loop ()
| Error (Exn (exn, bt)) -> (exn, Some bt)
Expand Down

0 comments on commit 0778c40

Please sign in to comment.