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

coloring to improve visibility #2711

Closed
blankRiot96 opened this issue Dec 21, 2021 · 3 comments · Fixed by #2712
Closed

coloring to improve visibility #2711

blankRiot96 opened this issue Dec 21, 2021 · 3 comments · Fixed by #2712
Labels
good first issue Good for newcomers S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: enhancement New feature or request

Comments

@blankRiot96
Copy link

Is your feature request related to a problem? Please describe.

It takes a bit of searching to find out how many files were reformatted and changed

Describe the solution you'd like

I think adding some simple coloring to the "x files reformatted, y files left unchanged" would be great, and also additionally leaving one line before "All done! ✨ 🍰 ✨" would be great too imo.

Describe alternatives you've considered

Adding some colons and such would help too, but I think adding some color would be better

Additional context
Here is an example of what I mean

image

@blankRiot96 blankRiot96 added the T: enhancement New feature or request label Dec 21, 2021
@ichard26 ichard26 added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label Dec 21, 2021
@ichard26
Copy link
Collaborator

I'd prefer if we stuck to the blue we already use for other messages and then use it for both stats as IMO it looks weird having two different colours for similar stats, but other than that I'm accepting this enhancement. I like it @blankRiot96!

@ichard26 ichard26 added the good first issue Good for newcomers label Dec 21, 2021
@blankRiot96
Copy link
Author

I'd prefer if we stuck to the blue we already use for other messages and then use it for both stats as IMO it looks weird having two different colours for similar stats, but other than that I'm accepting this enhancement. I like it @blankRiot96!

Thanks! Since you labelled it as a good first issue, I would love to work on it and make a PR. I have read the contributing guidelines too. If you don't mind, could you tell me where the output is handled in the src? 😓
I have looked at init.py and have understood that click is being used, which is great since I am familiar with it. And I am assuming the listing of reformatted files and the All done! message is being handled with echo
Was unable to find the output, but thanks again!

@MarcoGorelli
Copy link
Contributor

I presume you'd want to modify

black/src/black/report.py

Lines 79 to 104 in c5b458e

def __str__(self) -> str:
"""Render a color report of the current state.
Use `click.unstyle` to remove colors.
"""
if self.check or self.diff:
reformatted = "would be reformatted"
unchanged = "would be left unchanged"
failed = "would fail to reformat"
else:
reformatted = "reformatted"
unchanged = "left unchanged"
failed = "failed to reformat"
report = []
if self.change_count:
s = "s" if self.change_count > 1 else ""
report.append(
style(f"{self.change_count} file{s} {reformatted}", bold=True)
)
if self.same_count:
s = "s" if self.same_count > 1 else ""
report.append(f"{self.same_count} file{s} {unchanged}")
if self.failure_count:
s = "s" if self.failure_count > 1 else ""
report.append(style(f"{self.failure_count} file{s} {failed}", fg="red"))
return ", ".join(report) + "."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants