-
Notifications
You must be signed in to change notification settings - Fork 264
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
Install event support #573
Conversation
it can be used following "file_name_install" event nomenclature function foobar_install -e foobar_install echo "Installing foobar..." end
Hi @joseluisq. What's the use case here? |
@jorgebucaran when someone wants to perform a specific task once (during a package installation only). For instance, I want to download a third-party file (E.g a config file than I might update on every release) but only when users install the latest package. Actually I found no way to do this. |
|
||
set -l pkg_name (command basename $pkg .fish) | ||
|
||
if test "$pkg_name" = "$current_pkg_name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorgebucaran basically here I'm checking for emitting just once the event during installation.
Using your same uninstall
approach on _fisher_rm
function.
Lines 399 to 401 in c2b3ab0
case $pkg/conf.d\* | |
test "$filename.fish" = "$target"; and emit "$filename"_uninstall | |
set target conf.d/$target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this actually run only once? What happens when I run fisher
again? See #527
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this actually run only once?
Yes, when I say once I mean on every fisher add foobar
only.
Additionally, for example for new sessions created opening a new terminal tab, this event never gets emitted.
My concern was that I have no found a solution to make stuff on just every fisher add foobar
.
Unless you have another more proper way to do it.
What happens when I run fisher again?
I have tried many times and I didn't see issues. I only saw that the uninstall
event gets emitted at the beginning on the second attempt (related to #527), but then the normal install
event gets emitted just at the end of the installation.
I have tested this PR with my package on local which has both events defined. Then performing fisher add $PWD
many times as needed.
See #527
Is that already implemented or in progress?
Hi all, @joseluisq if I may make a suggestion, I think a cleaner way to execute only on package install is to through an |
@patrickf3139 |
I mean the file, not the function that is triggered by the uninstall event. Here is an example https://github.com/patrickf3139/open_github/blob/master/functions/uninstall.fish. |
@patrickf3139 Using an event is probably better. @joseluisq Would it be possible to achieve what you are trying to do using a conf.d snippet? Just want to make sure we're not reinventing the wheel here. |
@jorgebucaran Would you mind explaining why an event in a conf script is better than a |
It just seems to be that a file that only has to be read once when the plugin is installed vs a function that has to be re-read (though not executed most of the time) on every single fish invocation might be more elegant and efficient. |
@jorgebucaran can you provide me an example on how to do so?
@jorgebucaran I also support the Fish event emit functionality. |
I see, is the reason to use event handlers because fish already provides support for them, so it's less logic to have to include and maintain in fisher? |
I would also have a use for this feature in Tide where I want to offer the user the configuration wizard on first install but not on every shell startup. One could do this using a conf.d snippet that removes itself, but that seems unnecessarily awkward. |
@joseluisq Switching to You may create a new PR against the repo's new default branch, but I'd probably hold that off for now. I'll look into this when I start working on #582, at which point I'll probably rewrite this part entirely. See that Install, Update, and Uninstall event support will be introduced in one form or another in Fisher 4. 🎉 |
Did you switch from master to main to make the language more inclusive? If so, 👏 |
Definitely! |
I'm wondering whether you just closed this because of branch renaming or some future v4, what happen with the stable v3? However as a result of this approach, that I don't share, I'm going to stop resending any PR, leaving this to someone else if there is some interest on it. |
`_update`. Starting with 4.0 plugin authors should be able to reliably know when their plugin is installed, updated, or uninstalled. Related #526, #527 #573. - Remove "some" OMF plugin support (it won't go away completely since more than less of OMF plugins actually work fine). This means fully deprecating `init.fish`, `uninstall.fish`, etc. So long, and thanks for all the fish! Related: #581 - No cache fallback, no plugin dependencies, no more private package hosts, and no more gitlab/bitbucket support. #464, #579 - Require fish 3.0, use newer fish features, e.g., use `wait` to implement concurrent downloads. - Rely less on external tools. No awk, no sed, no basename/dirname. Just mv, rm, cp, and mkdir. Deprecate `fishfile` in favor of `fish_plugins`. This new file works like the old fishfile, but without comment support. See #524.
- Introduce event system. #526, #527 #573. - Deprecate `init.fish`, `uninstall.fish`, etc. #581 - No cache fallback, no plugin dependencies, no more private package hosts, and no more gitlab/bitbucket support. #464, #579 - Require fish 3.0, use newer fish features, e.g., use `wait` to implement concurrent downloads. - Rely less on external tools. No awk, no sed, no basename/dirname. Just mv, rm, cp, and mkdir. - Deprecate `fishfile` in favor of `fish_plugins`. This new file works like the old fishfile, but without comment support. See #524.
- Introduce new event system. #526, #527 #573. - Deprecate `init.fish`, `uninstall.fish`, etc. #581 - No cache fallback, no plugin dependencies, no more private package hosts, and no more gitlab/bitbucket support. #464, #579 - Require fish 3.0, use newer fish features, e.g., use `wait` to implement concurrent downloads. - Rely less on external tools. No awk, no sed, no basename/dirname. Just mv, rm, cp, and mkdir. - Deprecate `fishfile` in favor of `fish_plugins`. This new file works like the old fishfile, but without comment support. See #524.
Sorry for the great delay, but this is now finally implemented in 4.x. 🎉 cc @joseluisq @patrickf3139 |
Following the same aproach as the
uninstall
event, this PR adds support for a install event as well.This event can be used following
file_name_install
event nomenclature.Example:
In this case,
foobar_install
function will get called when thefoobar
package gets installed viafisher add foobar
.I have also refactored the documentation under the "Configuration snippets" section.