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 --no-color option to disable colored output on console #4402

Merged
merged 5 commits into from Feb 9, 2022

Conversation

cp2004
Copy link
Member

@cp2004 cp2004 commented Feb 5, 2022

What does this PR do and why is it necessary?

Add --no-color option to disable colored output on console.

Closes #4396

Also removed the setting of INFO logs to white, instead it will be left as default. If there is a light-colored background (such as white) then it becomes unreadable. Can then just use whatever user has configured for their default and not worry about contrast issues.

> octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]...

Options:
  -b, --basedir PATH  Specify the basedir to use for configs, uploads,
                      timelapses etc.
  -c, --config PATH   Specify the config file to use.
  --overlay PATH      Specify additional config overlays to use.
  -v, --verbose       Increase logging verbosity.
  --safe              Enable safe mode; disables all third party plugins.
  --no-color          Disable colored console output
  --version           Show the version and exit.
  --help              Show this message and exit.

How was it tested? How can it be tested by the reviewer?

Manually by starting with and without the flag.

Closes OctoPrint#4396

Also removed the setting of INFO logs to white, instead it will be left as default. If there is a light-colored background (such as white) then it becomes unreadable. Can then just use whatever user has configured for their default and not worry about contrast issues.
@github-actions github-actions bot added targets maintenance The PR targets the maintenance branch approved Issue has been approved by the bot or manually for further processing labels Feb 5, 2022
@cp2004 cp2004 linked an issue Feb 5, 2022 that may be closed by this pull request
4 tasks
Copy link

@zaitcev zaitcev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me, although weirdly different from existing code in a tiny detail.

@@ -307,6 +309,7 @@ def get_value(key):
safe_mode = "flag" if get_value("safe_mode") else None
ignore_blacklist = get_value("ignore_blacklist")
overlays = get_value("overlays")
no_color = bool(get_value("no_color"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing the style of boolean? The safe mode uses None-not-None, and we have Python bool for no-color. Seems perhaps unnecessarily inconsistent, if I may bikeshed a little.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe_mode is a special case, as it doesn't set a boolean value but rather a source of the safe mode activation. If it is anything but None, OctoPrint will run in safe mode, but it will log the reason for that based on the value of this flag.

However, the explicit cast to bool should indeed not be needed here, as this should already be a boolean thanks to being marked with is_flag=True in the click def.

@foosel foosel merged commit e9c33e1 into OctoPrint:maintenance Feb 9, 2022
@foosel foosel added this to the 1.8.0 milestone Mar 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Issue has been approved by the bot or manually for further processing targets maintenance The PR targets the maintenance branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standard output is unreadable on console
3 participants