Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --colors=always option for passing to click #239

Open
haluzpav opened this issue Mar 30, 2022 · 2 comments
Open

Add --colors=always option for passing to click #239

haluzpav opened this issue Mar 30, 2022 · 2 comments

Comments

@haluzpav
Copy link

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. 🙂

Screenshot 2022-03-30 at 19 50 07

@haluzpav
Copy link
Author

haluzpav commented Mar 30, 2022

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. 😁

@StanczakDominik StanczakDominik changed the title Colors are not preserved when output goes to variable Add --colors=always option Jan 23, 2023
@StanczakDominik
Copy link
Collaborator

StanczakDominik commented Jan 23, 2023

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? 🙂

@StanczakDominik StanczakDominik changed the title Add --colors=always option Add --colors=always option for passing to click Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants