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

Refactoring of the no-color flag #1218

Merged
merged 3 commits into from
Mar 10, 2022
Merged

Refactoring of the no-color flag #1218

merged 3 commits into from
Mar 10, 2022

Conversation

nblanke
Copy link
Contributor

@nblanke nblanke commented Dec 26, 2021

This PR improves the handling of the no-color flag by enabling/disabling color output with the colorama.init() function, thus making the if statements to check for color output redundant. Therefore, the code is more concise and clean.

Comment on lines +587 to +594

if args.no_color:
# Disable color output.
init(strip=True, convert=False)
else:
# Enable color output.
init(autoreset=True)

Copy link
Member

Choose a reason for hiding this comment

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

Would this be a better solution?

if not args.no_color:
    init(autoreset=True)

So by default color is on. If --no-color is used, then init(autoreset=True) is skipped because of the condition in the if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On my machine (OS X) that doesn't work. Even with the no-color flag, colored output is displayed. The reason for this behavior is that init() converts ANSI characters to win32 calls. That has no effect on Linux/OS X because there, colorama does nothing.

@sdushantha
Copy link
Member

sdushantha commented Mar 10, 2022

Sorry for getting back to you so late.

Everything looks good to me and I'll merge this PR right away. I really appreciate you taking the time and effort into doing the refactoring

@sdushantha sdushantha merged commit 28b49ef into sherlock-project:master Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants