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

Add commands to hatch cli from plugins #805

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

ThmX
Copy link

@ThmX ThmX commented Apr 1, 2023

As discussed in #798

  • Load command from plugins using pluggy
  • Create tests
  • Document the use of the hook

Small clarification concerning the implementation, it might feel strange that I did not use the normal PluginManager (i.e.: within hatch.cli.Application) but instead directly used natively pluggy. This is because a command created from an external plugin must be added to the hatch (which is of type click.Group) before it can be executed. (Otherwise, the command won't be able to be resolved -> it's basically the chicken and egg problem)

@ThmX
Copy link
Author

ThmX commented Apr 1, 2023

@ofek I'd like to create an automated test but couldn't find a way to make it run by installing a sample project and then showing that the command can be executed through hatch. Do you have an idea how I could test this? (I committed this attempt in c43a243)

shutil.copytree(importlib_resources.files(__package__) / "cli-plugin", project_dir)

with project_dir.as_cwd():
result1 = hatch("new", "--init")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
result1 = hatch("new", "--init")
hatch("new", "--init")

Copy link
Author

Choose a reason for hiding this comment

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

This is still in draft, that part is anyway not working (cf: #805 (comment)) -> forgot to add a TODO on top

@ThmX
Copy link
Author

ThmX commented Apr 16, 2023

@ofek I'd like to create an automated test but couldn't find a way to make it run by installing a sample project and then showing that the command can be executed through hatch. Do you have an idea how I could test this? (I committed this attempt in c43a243)

Any idea for this?

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