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

Overwrite to_info_dict() method in Context and command classes #175

Open
wabiloo opened this issue Jan 28, 2024 · 3 comments
Open

Overwrite to_info_dict() method in Context and command classes #175

wabiloo opened this issue Jan 28, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@wabiloo
Copy link

wabiloo commented Jan 28, 2024

The click context object has a method .to_info_dict() that's useful to go through the whole CLI structure, for example to write documentation.

It would be good to have an equivalent with cloup, so that all the other info cloup adds (eg. Aliases and help) can be exposed in the same way

@wabiloo wabiloo added the enhancement New feature or request label Jan 28, 2024
@janluke janluke changed the title Overloading ctx.to_info_dict Overwrite to_info_dict() methods in Context and command classes Jan 29, 2024
@janluke janluke changed the title Overwrite to_info_dict() methods in Context and command classes Overwrite to_info_dict() method in Context and command classes Jan 29, 2024
@janluke
Copy link
Owner

janluke commented Jan 29, 2024

Hi! This method seems to exist to generate a JSON representation of the CLI to be consumed by external tool. Do you know any of these external tool that make use of it? Note that this method not really useful for traversing the CLI: by converting to dict, you lose type information and autocomplete, which can only worsen your DX.

Anyway, you're welcome to contribute!

@wabiloo
Copy link
Author

wabiloo commented Jan 29, 2024

This one does, which creates an auto-complete for Fig: https://github.com/withfig/autocomplete-tools/blob/main/integrations/click/click_complete_fig/fig.py

But as I played with it yesterday (after starting this thread), I came to the same conclusion and converted to traverse the click/cloup object model instead. Really not complex, and in 10 min, the conversion was done and now I also have access to all of cloup's info...

@janluke
Copy link
Owner

janluke commented Jan 30, 2024

I'll keep this open for whoever wants to contribute.

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

No branches or pull requests

2 participants