Client: fix minor display glitches
This commit is contained in:
parent
3816c02958
commit
a1984ee090
@ -184,8 +184,8 @@ let main select_commands =
|
|||||||
Format.printf "@{<error>@{<title>Fatal error@}@} %s." (Printexc.to_string exn) ;
|
Format.printf "@{<error>@{<title>Fatal error@}@} %s." (Printexc.to_string exn) ;
|
||||||
Lwt.return 1
|
Lwt.return 1
|
||||||
end >>= fun retcode ->
|
end >>= fun retcode ->
|
||||||
Format.fprintf Format.std_formatter "@." ;
|
Format.pp_flush_formatter Format.std_formatter ;
|
||||||
Format.fprintf Format.err_formatter "@." ;
|
Format.pp_flush_formatter Format.err_formatter ;
|
||||||
Lwt.return retcode
|
Lwt.return retcode
|
||||||
|
|
||||||
(* Where all the user friendliness starts *)
|
(* Where all the user friendliness starts *)
|
||||||
|
@ -18,7 +18,7 @@ let get_commands_for_version ctxt block protocol =
|
|||||||
| Some given_version -> begin
|
| Some given_version -> begin
|
||||||
if not (Protocol_hash.equal version given_version) then
|
if not (Protocol_hash.equal version given_version) then
|
||||||
Format.eprintf
|
Format.eprintf
|
||||||
"@[<v 2>Warning:@,\
|
"@[<v 2>@{<warning>@{<title>Warning@}@}@,\
|
||||||
The protocol provided via `-protocol` (%a)@,\
|
The protocol provided via `-protocol` (%a)@,\
|
||||||
is not the one retrieved from the node (%a).@]@\n@."
|
is not the one retrieved from the node (%a).@]@\n@."
|
||||||
Protocol_hash.pp_short given_version
|
Protocol_hash.pp_short given_version
|
||||||
|
@ -293,6 +293,7 @@ let setup_formatter ppf format verbosity =
|
|||||||
Format.pp_get_formatter_tag_functions ppf (),
|
Format.pp_get_formatter_tag_functions ppf (),
|
||||||
Format.pp_get_print_tags ppf () in
|
Format.pp_get_print_tags ppf () in
|
||||||
begin
|
begin
|
||||||
|
Format.pp_flush_formatter ppf ;
|
||||||
Format.pp_set_formatter_out_functions ppf
|
Format.pp_set_formatter_out_functions ppf
|
||||||
{ out_string =
|
{ out_string =
|
||||||
(fun s b a ->
|
(fun s b a ->
|
||||||
@ -335,7 +336,8 @@ let setup_formatter ppf format verbosity =
|
|||||||
match format with
|
match format with
|
||||||
| Ansi ->
|
| Ansi ->
|
||||||
let color_num = function
|
let color_num = function
|
||||||
| `Black -> None
|
| `Auto -> None
|
||||||
|
| `Black -> Some 0
|
||||||
| `Red -> Some 1
|
| `Red -> Some 1
|
||||||
| `Green -> Some 2
|
| `Green -> Some 2
|
||||||
| `Yellow -> Some 3
|
| `Yellow -> Some 3
|
||||||
@ -353,7 +355,7 @@ let setup_formatter ppf format verbosity =
|
|||||||
with
|
with
|
||||||
| [] -> ()
|
| [] -> ()
|
||||||
| l -> Format.fprintf ppf "@<0>%s" ("\027[" ^ String.concat ";" l ^ "m") in
|
| l -> Format.fprintf ppf "@<0>%s" ("\027[" ^ String.concat ";" l ^ "m") in
|
||||||
let ansi_stack = ref [ (`White, `Black, false, false) ] in
|
let ansi_stack = ref [ (`Auto, `Auto, false, false) ] in
|
||||||
let push_ansi_format (fg, bg, b, u) =
|
let push_ansi_format (fg, bg, b, u) =
|
||||||
let format = match !ansi_stack with
|
let format = match !ansi_stack with
|
||||||
| (pfg, pbg, pb, pu) :: _ ->
|
| (pfg, pbg, pb, pu) :: _ ->
|
||||||
@ -378,12 +380,12 @@ let setup_formatter ppf format verbosity =
|
|||||||
| "title" -> push_ansi_format (None, None, true, true)
|
| "title" -> push_ansi_format (None, None, true, true)
|
||||||
| "commandline" -> Format.fprintf ppf "@[<hov 4>"
|
| "commandline" -> Format.fprintf ppf "@[<hov 4>"
|
||||||
| "commanddoc" -> Format.fprintf ppf " @[<v 0>"
|
| "commanddoc" -> Format.fprintf ppf " @[<v 0>"
|
||||||
| "opt" -> push_ansi_format (Some `Green, Some `Black, false, false)
|
| "opt" -> push_ansi_format (Some `Green, None, false, false)
|
||||||
| "arg" -> push_ansi_format (Some `Yellow, Some `Black, false, false) ; Format.fprintf ppf "<"
|
| "arg" -> push_ansi_format (Some `Yellow, None, false, false) ; Format.fprintf ppf "<"
|
||||||
| "kwd" -> push_ansi_format (Some `White, Some `Black, false, true)
|
| "kwd" -> push_ansi_format (Some `White, None, false, true)
|
||||||
| "error" -> push_ansi_format (Some `Red, Some `Black, true, true)
|
| "error" -> push_ansi_format (Some `Red, None, true, true)
|
||||||
| "warning" -> push_ansi_format (Some `Yellow, Some `Black, true, true)
|
| "warning" -> push_ansi_format (Some `Yellow, None, true, true)
|
||||||
| "hilight" -> push_ansi_format (Some `Black, Some `Yellow, false, true)
|
| "hilight" -> push_ansi_format (Some `White, Some `Yellow, true, true)
|
||||||
| "list" -> Format.fprintf ppf " @[<v 0>"
|
| "list" -> Format.fprintf ppf " @[<v 0>"
|
||||||
| "command" -> Format.fprintf ppf "@[<v 0>"
|
| "command" -> Format.fprintf ppf "@[<v 0>"
|
||||||
| "document" -> Format.fprintf ppf "@[<v 0>"
|
| "document" -> Format.fprintf ppf "@[<v 0>"
|
||||||
@ -497,6 +499,7 @@ let setup_formatter ppf format verbosity =
|
|||||||
orig_state
|
orig_state
|
||||||
|
|
||||||
let restore_formatter ppf (out_functions, tag_functions, tags) =
|
let restore_formatter ppf (out_functions, tag_functions, tags) =
|
||||||
|
Format.pp_flush_formatter ppf ;
|
||||||
Format.pp_set_formatter_out_functions ppf out_functions ;
|
Format.pp_set_formatter_out_functions ppf out_functions ;
|
||||||
Format.pp_set_formatter_tag_functions ppf tag_functions ;
|
Format.pp_set_formatter_tag_functions ppf tag_functions ;
|
||||||
Format.pp_set_print_tags ppf tags
|
Format.pp_set_print_tags ppf tags
|
||||||
@ -512,22 +515,22 @@ let usage_internal ppf ~executable_name ~global_options ?(highlights=[]) command
|
|||||||
"@{<document>@{<title>Usage@}@,\
|
"@{<document>@{<title>Usage@}@,\
|
||||||
@{<list>\
|
@{<list>\
|
||||||
@{<command>@{<commandline>\
|
@{<command>@{<commandline>\
|
||||||
%s [@{<opt>global options@}] command @{<opt>[command options]@}@}@}@,\
|
%s [@{<opt>global options@}] @{<kwd>command@} [@{<opt>command options@}]@}@}@,\
|
||||||
@{<command>@{<commandline>\
|
@{<command>@{<commandline>\
|
||||||
%s @{<opt>--help@} (for global options)@}@}@,\
|
%s @{<opt>--help@} (for global options)@}@}@,\
|
||||||
@{<command>@{<commandline>\
|
@{<command>@{<commandline>\
|
||||||
%s [@{<opt>global options@}] command @{<opt>--help@} (for command options)@}@}\
|
%s [@{<opt>global options@}] @{<kwd>command@} @{<opt>--help@} (for command options)@}@}\
|
||||||
@}@,@,\
|
@}@,@,\
|
||||||
@{<title>To browse the documentation@}@,\
|
@{<title>To browse the documentation@}@,\
|
||||||
@{<list>\
|
@{<list>\
|
||||||
@{<command>@{<commandline>\
|
@{<command>@{<commandline>\
|
||||||
%s [@{<opt>global options@}] man (for a list of commands)@}@}@,\
|
%s [@{<opt>global options@}] @{<kwd>man@} (for a list of commands)@}@}@,\
|
||||||
@{<command>@{<commandline>\
|
@{<command>@{<commandline>\
|
||||||
%s [@{<opt>global options@}] man @{<opt>-verbosity 3@} (for the full manual)@}@}\
|
%s [@{<opt>global options@}] @{<kwd>man@} @{<opt>-v 3@} (for the full manual)@}@}\
|
||||||
@}@,@,\
|
@}@,@,\
|
||||||
@{<title>Global options (must come before the command)@}@,\
|
@{<title>Global options (must come before the command)@}@,\
|
||||||
@{<commanddoc>%a@}%a\
|
@{<commanddoc>%a@}%a\
|
||||||
%a@}"
|
%a@}@."
|
||||||
executable_name executable_name executable_name executable_name executable_name
|
executable_name executable_name executable_name executable_name executable_name
|
||||||
print_options_detailed spec
|
print_options_detailed spec
|
||||||
(fun ppf () -> if by_group <> [] then Format.fprintf ppf "@,@,") ()
|
(fun ppf () -> if by_group <> [] then Format.fprintf ppf "@,@,") ()
|
||||||
@ -1251,7 +1254,7 @@ let pp_cli_errors ppf ~executable_name ~global_options ~default errs =
|
|||||||
pp acc errs in
|
pp acc errs in
|
||||||
Format.fprintf ppf "@[<v 2>@{<error>@{<title>Error@}@}@," ;
|
Format.fprintf ppf "@[<v 2>@{<error>@{<title>Error@}@}@," ;
|
||||||
let commands = pp [] errs in
|
let commands = pp [] errs in
|
||||||
Format.fprintf ppf "@]@.@[<v 0>%a@]"
|
Format.fprintf ppf "@]@\n@\n@[<v 0>%a@]"
|
||||||
(fun ppf commands -> usage_internal ppf ~executable_name ~global_options commands)
|
(fun ppf commands -> usage_internal ppf ~executable_name ~global_options commands)
|
||||||
commands
|
commands
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user