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

Enable help for positional arguments #11

Open
ewels opened this issue Feb 15, 2022 · 6 comments
Open

Enable help for positional arguments #11

ewels opened this issue Feb 15, 2022 · 6 comments
Labels
low priority new feature New feature or request

Comments

@ewels
Copy link
Owner

ewels commented Feb 15, 2022

Click deliberately does not support help for positional arguments.

I think it would be good to support this if people want, it is a bit more relevant with the rich-click tabular output.

To make this work, we need to enable an additional argument for the click.argument() function though, which is a little involved. Others have asked for this feature and some have done their own implementations, see pallets/click#587 (comment)

Should be able to recreate something like this in rich-click to add support for argument help.

@ewels ewels added the new feature New feature or request label Feb 15, 2022
@ewels ewels mentioned this issue Mar 3, 2022
@kdeldycke
Copy link

@ewels If you are looking to add help for arguments, you can use Cloup: https://cloup.readthedocs.io/en/stable/pages/arguments.html

@ewels
Copy link
Owner Author

ewels commented Jun 26, 2023

Nice, thanks for the tip! That's a good solution. Any idea how the output looks? If it works with rich-click already then I can just add a note in the readme..

@kdeldycke
Copy link

No idea how it looks like with rich-click. I am just a happy user of Cloup and I am only starting to explore the features of Rich and how it can augments Click CLIs! 😅

@wabiloo
Copy link

wabiloo commented Apr 6, 2024

@kdeldycke did you manage to make cloup and rich-click work together?

@dwreeves
Copy link
Collaborator

@wabiloo I know this isn't quite what you'd want, but you can use show_arguments in the config:

import rich_click as click

@click.command()
@click.argument("name")
@click.option("--count", default=1, help="Number of greetings.")
@click.rich_config(help_config={"show_arguments": True})
def hello(name, count):
    """Simple program that greets NAME for a total of COUNT times."""
    for _ in range(count):
        click.echo(f"Hello, {name}!")

if __name__ == '__main__':
    hello()
image

Still can't put help text in, but it is probably better than nothing if you want this.


Note: I do not intend on working on this feature myself for the foreseeable future, but just for lack of wanting to bother. I'm all for the feature existing as an option for users. Basically, I would accept a PR that wraps @click.argument() so that it takes a help kwarg. Easier said than done, to anyone who wants to try, but also not rocket science either.

@kdeldycke
Copy link

@kdeldycke did you manage to make cloup and rich-click work together?

No, I did not try. But I feel like by the time I'll play with rich, I'll simply integrate it with Click Extra, bypassing rich-click altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority new feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants