move rich console into function so we can mock properly

This commit is contained in:
Jonathan Wren 2022-05-28 13:51:02 -07:00
parent bdbd3ca2a6
commit 4636f1a3ef

View file

@ -70,12 +70,17 @@ def print_msgs(
decorated_text = style.decoration.callback(text, **kwargs) decorated_text = style.decoration.callback(text, **kwargs)
# Always print messages to stderr # Always print messages to stderr
console = Console(stderr=True) console = _get_console(stderr=True)
if get_input: if get_input:
return str(console.input(prompt=decorated_text, password=hide_input)) return str(console.input(prompt=decorated_text, password=hide_input))
console.print(decorated_text, new_line_start=style.prepend_newline) console.print(decorated_text, new_line_start=style.prepend_newline)
def _get_console(stderr: bool = True) -> Console:
return Console(stderr=stderr)
def _add_extra_style_args_if_needed(args, msg): def _add_extra_style_args_if_needed(args, msg):
args["border_style"] = msg.style.color args["border_style"] = msg.style.color
args["title"] = msg.style.box_title args["title"] = msg.style.box_title