-
Notifications
You must be signed in to change notification settings - Fork 38
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
Show commands before options #200
Comments
Thanks for writing this up @mirpedrol 👍🏻 I think it should basically be a question of having a config option that allows these lines to be executed in the opposite order: rich-click/src/rich_click/rich_command.py Lines 294 to 296 in 7662593
I might be oversimplifying it though. And it's worth thinking about what the best way to handle this config is, I know @dwreeves you've been working on refactoring a lot of the configuration lately.. Any thoughts on this? |
The way to do that right now without needing to wait on us would be something like this: import rich_click as click
class CustomRichGroup(click.RichGroup):
def format_options(self, ctx, formatter) -> None:
from rich_click.rich_help_rendering import get_rich_options
self.format_commands(ctx, formatter)
get_rich_options(self, ctx, formatter)
@click.group(cls=CustomRichGroup)
def cli():
... I tested this in my code and it works! Also, I believe the above code only works for versions 1.8+; I believe in 1.7 we didn't separate out commands+options, and in prior versions subclassing was not well-supported. We could also implement this as a config option. It will take me either until this or next weekend to get around to it, though, but it's a relatively simple change. |
Also, I should say, if you'd like to contribute to this, you certainly can, but we need to think through implementation. My first thought is we could do something like The issue though is that, in 1.9 (target release is end of year), we intended on doing a complete revamp of the "panels" functionality (currently called "groups"). See #179 for more info on that. I don't know what the implementation will ultimately end up being for panels, but a possible implementation of that might be the act of combining all panels into a single interface and distinguishing them by type, e.g. And if we opt to have @click.group
@click.argument("bar")
@click.option("--foo")
@click.rich_config({"show_arguments": True}, panels=["Arguments", "Commands", "Options"]) # defines order
def cli():
... ^ That said, if we implement this, then my suggestion of subclassing breaks in 1.9! 😆 Since we'd need to re-combine the format_options + format_commands and break from how base click does things. 🙊 No good solutions, eh.... Anyway, to bridge the gap in the meanwhile (since this is targeted for 6 months out), would could add |
This sounds like a sensible plan of action 👍🏻 Thanks @dwreeves ! |
Hi @dwreeves, thanks for all the information! |
Hello!
Is there a way to show the command groups before the options on the help output?
We are using rich-click on nf-core with the following help output (see screenshot) and we would like to see the commands at the top, as those are more important than the options we show.

I would be happy to contribute if this can help. I would appreciate any pointers on how to achieve this. Thank you!
The text was updated successfully, but these errors were encountered: