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

Rich-click does not format nested commands #86

Closed
davidfokkema opened this issue Sep 11, 2022 · 7 comments
Closed

Rich-click does not format nested commands #86

davidfokkema opened this issue Sep 11, 2022 · 7 comments

Comments

@davidfokkema
Copy link

Nested commands are not formatted at all. Because I couldn't get my script to work correctly I tried the simple example script. I get:

$ python rich_click_ex1.py

 Usage: rich_click_ex1.py [OPTIONS] COMMAND [ARGS]...

 My amazing tool does all the things.
 This is a minimal example based on documentation from the 'click' package.
 You can try using --help at the top level and also for specific group
 subcommands.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --debug/--no-debug  -d/-n    Enable debug mode. Newlines are removed by      │
│                              default.                                        │
│                              Double newlines are preserved.                  │
│ --help                       Show this message and exit.                     │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ download  Optionally use short-help for the group help text                  │
│ sync      Synchronise all your files between two places. Example command     │
│           that doesn't do much except print to the terminal.                 │
╰──────────────────────────────────────────────────────────────────────────────╯

This works as advertised. However:

$ python rich_click_ex1.py sync --help
Debug mode is off
Usage: rich_click_ex1.py sync [OPTIONS]

  Synchronise all your files between two places. Example command that
  doesn't do much except print to the terminal.

Options:
  --type TEXT  Type of file to sync  [default: files; required]
  --all
  --help       Show this message and exit.

This does not work as advertised. Am I missing something? Should the example script be updated or is this a bug?

@ewels
Copy link
Owner

ewels commented Sep 11, 2022

Hmm, it's working fine for me:

$ python 01_simple.py sync --help
Debug mode is off

 Usage: 01_simple.py sync [OPTIONS]

 Synchronise all your files between two places. Example command that doesn't do
 much except print to the terminal.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ *  --type    TEXT  Type of file to sync [default: files] [required]          │
│    --all                                                                     │
│    --help          Show this message and exit.                               │
╰──────────────────────────────────────────────────────────────────────────────╯

How are you installing rich-click? What version are you using?

@davidfokkema
Copy link
Author

I'm terribly sorry. I was working on an old project which, it turns out, had an outdated version of click specified in its pypoetry.toml. Note to self: always test in a clean environment with the latest version of everything. 🙈

@davidfokkema
Copy link
Author

Love your project, by the way!

@ewels
Copy link
Owner

ewels commented Sep 11, 2022

Ah phew, glad you got it sorted 😅 If you happen to know what version of click it was that would be useful, I can pin a minimum requirement to avoid it in the future perhaps..

@davidfokkema
Copy link
Author

It turns out I started this little side project just before Click v8 was released. click==7.1.2 does not work. click==8.0.0 does work. So click>=8.0.0 should do the trick, 😅. Thanks!

@ewels
Copy link
Owner

ewels commented Sep 12, 2022

Thanks 🙌🏻

I was curious as to whether I could back-port support but having glanced over the click changelog I suspect that it's not trivial.

Version 8 was released 2021-05-11 which is actually not all that long ago. Rich-click currently pins click>=7 which was released 2018-09-25 (I think it crashes with v6x). Because this problem with v7x doesn't actually crash the program, just reverts to the previous default click behaviour, I think I'll play it safe and leave the pin as it is for now. There may be people with reasons for not upgrading yet and if they're not using subcommands it'll be working fine, and if they are it's not the end of the world.

I'll add a note to the readme though 🙂

Phil

ewels added a commit that referenced this issue Sep 12, 2022
@davidfokkema
Copy link
Author

I'll add a note to the readme though 🙂

Great, thanks! That will save the next person some time, 😀.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants