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

Support disable color and switch off color when stdout is not a TTY #67

Merged
merged 32 commits into from
Jun 30, 2022

Conversation

laixintao
Copy link
Collaborator

@laixintao laixintao commented Jun 23, 2022

You can disable color output by setting colorful-output = False in ~/.pdir2config now.

Example:

[global]
colorful-output = True

True means always use color, False means always disable color, and auto means using color output when stdout is a TTY, otherwise not.

You can also disable colors by environment variable export PDIR2_NOCOLOR=1. The environment has higher priority than the config file.

close #65

@laixintao
Copy link
Collaborator Author

I added a fake color render COLOR_DISABLED to render plain text without escape code.

If it is ok for you, then I will complete this PR with more docs and test cases. @laike9m

@laixintao laixintao marked this pull request as ready for review June 25, 2022 05:58
@laixintao
Copy link
Collaborator Author

I don't have permission to edit doc in wiki so i put the doc in this description, you can copy it to wiki.

and I don't mind if you squash merge, the commit log is a bit messy due to fixing the ci. @laike9m

pdir/configuration.py Outdated Show resolved Hide resolved
@laixintao laixintao requested a review from laike9m June 27, 2022 03:21
@laike9m
Copy link
Owner

laike9m commented Jun 27, 2022

Let me know if I need to review

@laixintao
Copy link
Collaborator Author

@laike9m I applied you suggestions already, please review again and leave some comments if there is anything more need to be improved.

pdir/configuration.py Show resolved Hide resolved
pdir/configuration.py Outdated Show resolved Hide resolved
return False

if (
_cfg.colorful_output is None or _cfg.colorful_output == "auto"
Copy link
Owner

Choose a reason for hiding this comment

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

Not quite sure where the default value is set, mind elaborate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

default value is None which has the same effect with "auto"

pdir/configuration.py Outdated Show resolved Hide resolved
pdir/configuration.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
@laixintao laixintao requested a review from laike9m June 28, 2022 15:58
pdir/color.py Outdated Show resolved Hide resolved
pdir/configuration.py Outdated Show resolved Hide resolved
@laixintao
Copy link
Collaborator Author

ready for review again, you can merge #68 first

@laixintao laixintao closed this Jun 29, 2022
@laixintao laixintao reopened this Jun 29, 2022
@laixintao
Copy link
Collaborator Author

refactored some import pdir move them to top if necessary.

@laike9m
Copy link
Owner

laike9m commented Jun 30, 2022

LGTM, thanks again!

@laixintao laixintao merged commit a32a958 into laike9m:master Jun 30, 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.

Disable coloring doesn't work?
2 participants