mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
move rich console into function so we can mock properly
This commit is contained in:
parent
bdbd3ca2a6
commit
4636f1a3ef
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue