Closed LCVcode closed 1 week ago
Any work done here must not affect Jockey's ability to be piped into other commands. Pipeline compatibility is a first principle for this project.
I hard agree. To approach this, we will want to use the isatty
call (e.g., sys.stdin.isatty()
).
Likewise, it does appear rich
will make a best effort to do this automatically.
What is your opinion on using this to gate text formatting (e.g., readability indentation, etc.)? Suppose we have accurate detection of output capturing and redirection -- should we attempt to "prettify" the output when the user is the final reader of the output?
I think beautifying the output would be an excellent feature when humans are the final reader. One question that comes to my mind is how will this interact which Jockey outputs are set as a variable, which I would expect to see done quite frequently in playbooks and hopefully generally out in the wild.
UNITS=$(jockey units)
need to not be beautified for the sake of scripting.
I created a small demo of the auto-detection to confirm our requirements here:
from rich.console import Console
console = Console()
print(f"color_system: {console.color_system}")
print(f"is_terminal: {console.is_terminal}")
print(f"is_dumb_terminal: {console.is_dumb_terminal}")
Using this, I can confirm that all of our expectations are covered.
python3 ./rich-test.py
color_system: truecolor
is_terminal: True
is_dumb_terminal: False
test="$(python3 ./rich-test.py)"; echo "${test}"
color_system: None
is_terminal: False
is_dumb_terminal: False
stdout
(expect no color)(note: on my system, cat
is rebound to rcat
)
python3 ./rich-test.py | rcat
color_system: None
is_terminal: False
is_dumb_terminal: False
We should look into using rich as a way to spice up Jockey outputs to improve readability and generally make them more interesting/fun. I would like to see some example outputs from people who feel that outputs should be colored in a particular way.
Any work done here must not affect Jockey's ability to be piped into other commands. Pipeline compatibility is a first principle for this project.
Blocked by #19