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

Highlights options, choices and metavars #95

Closed
kdeldycke opened this issue Oct 7, 2021 · 4 comments
Closed

Highlights options, choices and metavars #95

kdeldycke opened this issue Oct 7, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@kdeldycke
Copy link
Contributor

kdeldycke commented Oct 7, 2021

I just discovered cloup and it is fantastic! It's basically an up-to-date bundle of all the unmaintained click-contrib utilities! 😍

I developed some code in my mail-deduplicate CLI some month ago to automatically highlights all options, choices and metavars in help screens generated by click. See how it renders:

cli-colored-help

For reference, here is my current implementation: https://github.com/kdeldycke/mail-deduplicate/blob/develop/mail_deduplicate/colorize.py

@janluke, would you be interested by my attempt at integrating my extra-highlight logic into cloup's help formatting code?

@janluke
Copy link
Owner

janluke commented Oct 7, 2021

I just discovered cloup and it is fantastic!

Thank you! Glad you like it!

would you be interested by my attempt at integrating my extra-highlight logic into cloup's help formatting code?

A more fine-grained theming (metavars and defaults) was something I tried to implement when I first introduced the theming feature! Unfortunately, click is not very well designed when it comes to formatting. Formatting logic is splitted in many components and the so called HelpFormatter is just a low-level formatter. So I ultimately decided to give up or at least to leave a more fine-grained formatting for the future at the time. Even because, in theory, Click should get a new formatting system soon or later (though I'm starting to doubt it'll ever come out), so I didn't want to waste too much time on the current one.

Coming to you proposal, I'm all in for adding the feature, of course, but using regular expressions looks more like a workaround to me :(

@kdeldycke
Copy link
Contributor Author

A more fine-grained theming (metavars and defaults) was something I tried to implement when I first introduced the theming feature!

Aha, great minds think alike! I guess we both reached the conclusion that finer highlighting increase the readability of help screens.

I just had a look at your bug reports and PRs to Click project. And realized how much work it takes to already have that flexible help in Cloup. Thanks a lot for your dedication and thanks for making Click better!

Now for that extra-highlighting. I understand you do not want to taint Cloup's clean code with ugly regexps. 😉 My rationale was that help screen are not consumed by machine but are designed for human. So a hack was good enough and a good compromise.

Ideally we should have proper fine-grained support of semantics in Click. I guess this is more or less covered by that mega-issue: pallets/click#561

Anyway, feel free to close this issue if it doesn't make sense. I think I'll still try to piggy-back on Cloup in my CLIs and re-adapt my regexps to its logic (depending on my motivation).

@janluke
Copy link
Owner

janluke commented Oct 9, 2021

Aha, great minds think alike!

;)

I just had a look at your bug reports and PRs to Click project. And realized how much work it takes to already have that flexible help in Cloup. Thanks a lot for your dedication and thanks for making Click better!

Thank you, I appreciate it! It was a lot of work indeed.

Now for that extra-highlighting. I understand you do not want to taint Cloup's clean code with ugly regexps. 😉 My rationale was that help screen are not consumed by machine but are designed for human. So a hack was good enough and a good compromise.

It's totally okay to do that at the application level but it's still a workaround. I've made use of workarounds in Cloup but in this case "there must be a better way" (quote).

Furthermore, I was thinking that maybe rather than improving the console help page, it's better to invest time in generating HTML documentation / man pages and opening the browser when the user runs --help (if there is a browser), as git does.

Anyway, feel free to close this issue if it doesn't make sense.

I'll close this issue and open a new one that references this one, since I'm open to include the feature. Unfortunately I've no time for this right now :(.

@kdeldycke
Copy link
Contributor Author

FYI, I just release click-extra with all my additional help screen colorization code. It might need some polishing but it is good enough and reasonably tested to be used by others.

kdeldycke added a commit to kdeldycke/click-extra that referenced this issue Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants