-
Notifications
You must be signed in to change notification settings - Fork 26
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
CLI Plugins #130
Comments
Sounds good to me! 👍 |
Hello there, I was looking for a kind of interceptor/plugin for citty that I could hook without changing a command's code, and stumbled upon #98 and this issue. @Barbapapazes made some initial work on it, I was wondering if there was any other conversation to resume or abandon the idea? My use case is the following: There's a cli using citty, and we wanted to do a wrapper on top of it for a few commands of ours. So we import it's main defineCommand, merge with our commands and provide that to the main defineCommand as subcommands. For a command ABC from said cli, I'd like it to invoke N commands/functions of mine before/after, but not touch anything the other CLI does because I want it's behavior to happen. So, in that fashion, I think we can just make a setup() on our main defineCommand which will check the But I was wondering if a plugin would look cleaner? idk. Visually the suggested approach felt just like vue2 mixin which I liked to use back then so I'm biased lol. |
inspired from #98 (comment) by @jgoux
With plugins, we can allow them to intercept to different hooks but also preserve their context. We can extend to more hooks if needed.
Example:
The text was updated successfully, but these errors were encountered: