-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for cv plugins #191
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
Conversation
a15109d to
8213535
Compare
|
civibot, test this please |
|
This might be problematic.
Brainstorming:
|
|
Rebased. Added a unit-test for a plugin which defines a new |
|
I suspect most of the test-failures are because the test-matrix is written in the older style. This leads to testing some invalid combinations like |
|
OK, after some general house-keeping on the repo (switch to phpunit9+duderino) and a rebase, the tests are passing. Also added some coverage for the internal hook that enables plugins to define |
510f432 to
ae50ef9
Compare
|
Hi, Martin from the civicamp Hamburg here: best, Martin |
|
civibot, test this please |
This is heavily based on the loco's plugin subsystem. The main adaptations are: * Change class names. * Put the code in `cv-lib` so that affiliate commands (`coworker`, `civix`) can use the same plugin subsystem. * Don't use Symfony EventDispatcher. This makes it easier to include in `cv-lib`.
…-existing "@" arguments.
Similar to Civix
acc4c1b to
393f78f
Compare
|
Cheers @vurt2 - very glad it worked. Agree it would be handy for extensions to bundle cv-plugins, though doing so requires sorting some bootstrap issues. (I think... it requires a 2-phase command-dispatcher; an earlier phase to dispatch early/built-in commands like I had to do a few minor updates to accommodate recent Symfony 5/PHP8.4 updates. (In the example plugin-commands, the But it's passing again. 🟢 |
|
@totten Very cool. Thanks for the work! |
|
JFYI @vurt2 - For cv v0.3.56, I've done some rearranging of the command classes. Strictly speaking, the examples from before should still work the same way. However, the examples from before were missing important things... like, they didn't actually bootstrap CiviCRM. (They just said "Hello"...) And this undocumented part changed (#218) -- most notably, with the introduction of a new base-class I've updated the doc file: https://github.com/civicrm/cv/blob/master/doc/plugins.md |
|
Thanks for the update @totten - yes, I had to boot cv with "$this->boot()". Cool, that you added this. I encountered a small typo in the plugins.md: the use of functione instead of function in the structured-class style example. |
Overview
Adds support for loading plugins (
*.phpfiles) to modify the behavior ofcv. In particular, some useful things you might do are (a) defining new subcommands or (b) defining alias services (cv @mysite ext:list).The design is based on heavily on loco CLI plugins.
Plugin Loading
Plugins are loaded from the
CV_PLUGIN_PATH. If the path is not set, then it loads PHP files from these folders:$HOME/.cv/plugin/etc/cv/plugin/usr/local/share/cv/plugin/usr/share/cv/pluginEach plugin is a
*.phpfile.Example: "Hello" Command
For example, to implement
cv hello, you could create:The file
doc/plugins.mdgives more details.Example: Site Aliases
Additionally, I've drafted a bigger example with support for site-aliases, eg
The draft is at https://gist.github.com/totten/8241b80440221555c0051d4f3447fa40
Why do this as a plugin? Well, there are several little questions to sort out. Like:
$HOME/.cvor/etc)? Or do you have contextual aliases (like@prodand@stagingfor a specific site)?drushconfig-files,wp-cliconfig-files, orcivibuildconfig-files?Whatever the eventual answers, we'd probably want to include something like this in
cvby default. But TBH, I'm kinda ambivalent about the details of those questions. Seems appealing to incubate as a plugin...Documentation
The PR also adds a file
doc/plugins.md.