-
Couldn't load subscription status.
- Fork 4
Add colors and formatting to dispatch-cli #110
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
Conversation
Signed-off-by: Mathias L. Baumann <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! It might also be a good idea to maybe set constants with colors, so they are easier to tune if needed, like COLOR_DISPATCH_STARTED, VALUE_NONE_COLOR, COLOR_VALUE_TRUE, etc.
But all comments optional.
| """Print the dispatch details in a nicely formatted way with colors.""" | ||
| # Determine the status and color | ||
| status: str = "running" if dispatch.started else "not running" | ||
| status_color: str = "green" if dispatch.started else "red" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: What about gray for not started? Red looks like an error to me. Maybe we can sort of mimic systemctl status as many users may be familiar with them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My desire was that it stands out immediately what the status is :)
| val_color = "white" | ||
|
|
||
| if value in ("None", "False"): | ||
| val_color = "red" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here maybe gray for None?
| required=True, | ||
| ) | ||
| @click.option( | ||
| "--raw", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible future improvements:
- Split
--rawfrom--no-color - Set color on/off automatically based on
sys.stdin.isatty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set color on/off automatically based on sys.stdin.isatty()
that actually seems to happen automatically, at least there is no color if I pipe it through cat or forward it into a file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool. Extra point for click 💯
Uh oh!
There was an error while loading. Please reload this page.