Add `--colors=always` option for passing to `click`
haluzpav opened this issue · comments
When I do var="$(toggl now)"
and then echo $var
, the output is not colored, as when I do just toggl now
. This works with other commands, tldr
for example.
- toggl, version 2.4.3
- zsh 5.8 (x86_64-apple-darwin21.0)
If this is caused by some misconfiguration or twisted expectations on my side, I'm sorry. Please let me know. 🙂
I guess it's because we want plain text when e.g. outputing to a file, huh? I figured out how to bypass that for my use-case with unbuffer
. So let me rephrase the issue:
It's be nice if toggl
had a --colors=always
parameter. 😁
Here's the relevant bit of click docs, a color
flag to click.echo
:
color (Optional[bool]) – Force showing or hiding colors and other styles. By default Click will remove color if the output does not look like an interactive terminal.
So this is definitely possible, but would require a replacement of, most likely, every single call to click.echo
( a quick rg echo | wc -l
puts this at 61 occurences) with something like toggl.helpers.echo
(placement to be discussed!), which would be a thin wrapper around click.echo
that checks the config (from toggl/utils/config.py
?) for a new --colors
flag (None
by default) and passes that.
@haluzpav, would you be open to submitting a pull request? 🙂