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

feat: allow arbitrary command classes #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jayceslesar
Copy link

Add a new option :command_class that allows a user to specify a custom type for a command class, which will then attempted to be imported. Defaults to click.BaseCommand.

Closes #80

@jayceslesar
Copy link
Author

jayceslesar commented Jan 22, 2025

Ah there is more too this because https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L104 looks like a decent amount of those. Do we want to support a special option for each one of those checks?

@jayceslesar
Copy link
Author

yeah would need to specify options for the following:

  1. command_class (already implemented in existing commits)
  2. multicommand_class https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L104
  3. option_class https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L219
  4. choice_class https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L268
  5. datetime_class https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L274
  6. intrange_class https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L280
  7. floatrange_class https://github.com/mkdocs/mkdocs-click/blob/master/mkdocs_click/_docs.py#L280

Seems feasible to just default to all the click ones as a default and use the same pattern that is added so far for command_class ?

@ofek
Copy link
Collaborator

ofek commented Jan 27, 2025

After looking closer into https://github.com/python-trio/asyncclick, I'm hesitant to document the feature but I think it's okay if you add options for each of those as long as they are prefixed by something (and again, undocumented). I think that library is fundamentally wrong for literally forking the code rather than wrapping (in which case click objects would work because of subclassing).

I would appreciate feedback from @oprypin as I really think that library got it wrong.

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.

Fail to Build with asyncclick
2 participants