-
Notifications
You must be signed in to change notification settings - Fork 2
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
Coloured CLI output #4
Comments
I hope this communication finds you in good health. I'm writing to inquire about the spcache project and the outstanding issue "Adding Coloured Text to --help Option." I am passionate about this topic and would like to contribute to the project by assisting with its implementation. |
Hello, rich-click is a secondary goal. You could make a PR for simple coloured text first |
@Qwerty-133 I was browsing over the rich-click documentation, and it states to use import rich_click as click. After doing this, the help prompt looks excellent, and the spcache works properly after the import. Should I create the PR using rich-click or just skip and go for simple coloured text as you ask |
See ewels/rich-click#114 import rich_click as click
class ExceptionBase(click.ClickException):
"""
Base class for exceptions raised by this CLI tool.
Supports reading the message from a class variable.
"""
exit_code: t.ClassVar[int]
message: t.ClassVar[str]
def __init__(self) -> None:
super().__init__(self.message)
class FileDetectionError(ExceptionBase):
"""Raised when the Spotify prefs file can't be auto-detected."""
exit_code = 2
message = (
"The Spotify prefs file couldn't be auto-detected."
"\nPlease specify a path to the prefs file using the --file option."
)
def handle_file(
ctx: click.Context, file: t.Optional["dotenv.main.StrPath"], no_prompts: bool
) -> "dotenv.main.StrPath":
if file is None:
from spcache import detect
file = detect.detect_prefs_file()
if file is None:
raise FileDetectionError
... |
Hey @C0DE-SLAYER, could you provide an update on the status of this PR? Thanks! |
Hey @Qwerty-133 if you would mind can you explain me what i have to do for now i will make a pull request for the early request of your which was "We shouldn't go overboard with the colours, success messages in green, warnings in yellow, and errors in red is pretty much all we need." and looking forward for the rich_click implementation is that good. Thanks! |
@Qwerty-133 I have open a pull request check it out |
spcache doesn't use any colours right now,
click.secho
can be used to print coloured text for important text.https://github.com/ewels/rich-click can be looked into for pretty help outputs, however there will be some added overhead of importing
rich
.There should however be a way to use callbacks for
--help
and then delegate to rich-click, so rich-click doesn't need to be imported unless the user uses the--help
optionThe text was updated successfully, but these errors were encountered: