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

Conquer the land of clicketing snakes #13

Merged
merged 17 commits into from
Feb 28, 2022

Conversation

pawamoy
Copy link
Contributor

@pawamoy pawamoy commented Feb 19, 2022

Twin sister of chriskiehl/Gooey#788 :D
Original PR title: Allow to run any Click program from the CLI :p

@pawamoy pawamoy marked this pull request as draft February 19, 2022 13:04
@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 19, 2022

Just had to change a bit the imports in __init__.py to avoid infinite recursion 🙂

EDIT: hmm the arguments are not passed correctly, back to draft.

@pawamoy pawamoy marked this pull request as ready for review February 19, 2022 13:07
@pawamoy pawamoy marked this pull request as draft February 19, 2022 13:09
@pawamoy pawamoy marked this pull request as ready for review February 19, 2022 13:18
@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 19, 2022

Any examples of projects using Click so I can test it on them? HTTPX seems to use its own formatted help (same output with and without rich-click).

src/rich_click/cli.py Outdated Show resolved Hide resolved
src/rich_click/__main__.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
src/rich_click/__main__.py Outdated Show resolved Hide resolved
@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 19, 2022

Well that's nice.

rich_uvicorn

@ewels
Copy link
Owner

ewels commented Feb 19, 2022

Brilliant stuff! 👏🏻

I'm on holiday this week so won't get a chance to properly review + merge until after that, but love the idea / look of it..

Phil

@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 19, 2022

No problem, enjoy your holidays!

@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 22, 2022

So there's just one more thing to decide on: whether to implement rich-click's own CLI with click or not.

@ewels
Copy link
Owner

ewels commented Feb 22, 2022

Yeah I did wonder about commenting about that! Seems a bit hypocritical not to somehow 😅

Copy link
Owner

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I had a stab at running locally but ran into some issues..

src/rich_click/cli.py Outdated Show resolved Hide resolved
@ewels
Copy link
Owner

ewels commented Feb 28, 2022

Note to self: need to add the new entry points into the conda-forge meta.yml after this is released.

Example here, so something like this I guess:

build:
  entry_points:
    - rich-click=rich_click.cli:main

@ewels
Copy link
Owner

ewels commented Feb 28, 2022

That fixed it! 🎉

@ewels
Copy link
Owner

ewels commented Feb 28, 2022

ok, so using click to handle the CLI was difficult because of the weird argument handling (we don't want click to interpret any option flags).

Instead, I tried to fake it - using as many of the rich-click functions and variables as possible so that the help text tracks with updates to the package.

This is what I now get:

image

I'll push this directly to your PR if that's ok @pawamoy - I should PR to your feature branch really, but it's late.. 😁

@ewels
Copy link
Owner

ewels commented Feb 28, 2022

Now also spits out an informative error message if the command isn't found, or the full usage if just rich-click or rich-click --help:

image

Copy link
Owner

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, working a treat in my hands now - thanks for this!

I don't think I'd have ever believed that this would work had you not put in this PR 😅

@pawamoy
Copy link
Contributor Author

pawamoy commented Feb 28, 2022

I'll push this directly to your PR if that's ok @pawamoy

Totally fine!

And great work! I feared indeed that rewriting the CLI using click would be tricky, but you managed to do it well 😄

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

Successfully merging this pull request may close these issues.

None yet

2 participants