diff --git a/otherlibs/stdune/src/user_message.ml b/otherlibs/stdune/src/user_message.ml index 444d5cddf42..6560f3477dc 100644 --- a/otherlibs/stdune/src/user_message.ml +++ b/otherlibs/stdune/src/user_message.ml @@ -311,3 +311,9 @@ let command cmd = ; Pp.verbatim "'" ] ;; + +let aligned_message ~left:(left_tag, left_string) ~right = + let open Pp.O in + let left_padded = Printf.sprintf "%12s" left_string in + Pp.tag left_tag (Pp.verbatim left_padded) ++ Pp.char ' ' ++ right +;; diff --git a/otherlibs/stdune/src/user_message.mli b/otherlibs/stdune/src/user_message.mli index 854f4e5a8f7..a7872159129 100644 --- a/otherlibs/stdune/src/user_message.mli +++ b/otherlibs/stdune/src/user_message.mli @@ -124,3 +124,8 @@ val needs_stack_trace : t -> bool (** Formatting of shell commands *) val command : string -> Style.t Pp.t + +(** A message with a left and right component separated by a + space. The left component is padded to 12 characters so that the space + separating the left and right side of all messages are aligned. *) +val aligned_message : left:Style.t * string -> right:Style.t Pp.t -> Style.t Pp.t diff --git a/src/dune_engine/process.ml b/src/dune_engine/process.ml index a1ddca60a0d..67e1aaf8b5a 100644 --- a/src/dune_engine/process.ml +++ b/src/dune_engine/process.ml @@ -425,9 +425,9 @@ end = struct ;; let progname_and_purpose ~tag ~prog ~purpose = - let open Pp.O in - let progname = sprintf "%12s" (Fancy.short_prog_name_of_prog prog) in - Pp.tag tag (Pp.verbatim progname) ++ Pp.char ' ' ++ pp_purpose purpose + User_message.aligned_message + ~left:(tag, Fancy.short_prog_name_of_prog prog) + ~right:(pp_purpose purpose) ;; let pp_ok = progname_and_purpose ~tag:Ok diff --git a/src/dune_rules/pkg_build_progress.ml b/src/dune_rules/pkg_build_progress.ml index d6b9b281fc0..1ff0c4fad2d 100644 --- a/src/dune_rules/pkg_build_progress.ml +++ b/src/dune_rules/pkg_build_progress.ml @@ -15,7 +15,7 @@ end let format_user_message ~verb ~object_ = let status_tag = User_message.Style.Success in User_message.make - [ Pp.concat ~sep:Pp.space [ Pp.tag status_tag (Pp.textf "%12s" verb); object_ ] ] + [ User_message.aligned_message ~left:(status_tag, verb) ~right:object_ ] ;; module Message = struct