ewels / rich-click

Format click help output nicely with rich.
https://ewels.github.io/rich-click/
MIT License
630 stars 36 forks source link

[Draft] Rewrite `rich-click` CLI with a `RichCommand` #158

Closed dwreeves closed 9 months ago

dwreeves commented 9 months ago

Resolves #155 and adds a new feature to the rich-click CLI: --rich-config [JSON], which allows the user to set a config for a command they're wrapping with rich-click. Note that --rich-config should also work not just for normal click commands but also rich-click commands.

This is a work in progress, and needs a lot of testing.

dwreeves commented 9 months ago

Also addressing #124 in this PR. cli.py is now covered by tests 😄

dwreeves commented 9 months ago

I think this should be fine.

One minor change. I removed this:

    if len(args) > 1:
        if args[1] == "--":
            del args[1]

If someone is doing something really weird, e.g. rich-click -- -- flask -- run, then this could break backwards compatibility? However, the thing is, Click already handles e.g. rich-click -- flask -- run just fine. And my unit-tests assert as much. So I believe that the manual removal of the -- was always unnecessary.

I am making a note here in the very off chance this does break someone's setup, but I do not think that will be an issue.