Skip to content

Commit ebaf085

Browse files
committed
Pass plugin names as arguments (#788)
1 parent 2efd33c commit ebaf085

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Diff for: README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,22 @@ Non `.fish` files and directories inside these locations will be copied to `$fis
130130

131131
### Event system
132132

133-
Fish [events](https://fishshell.com/docs/current/cmds/emit.html) notify plugins when they're being installed, updated, or removed.
133+
Fisher notifies plugins when they're being installed, updated, or removed via [events](https://fishshell.com/docs/current/cmds/emit.html). Each relevant event handler is invoked with the plugin's name supplied as the first argument.
134134

135-
> Keep in mind, `--on-event` functions must be loaded when their event is emitted. So, place your event handlers in the `conf.d` directory.
135+
> Place your event handler functions in the `conf.d` directory to ensure they're loaded and ready when needed.
136136
137137
```fish
138138
# Defined in flipper/conf.d/flipper.fish
139139
140-
function _flipper_install --on-event flipper_install
140+
function _flipper_install --on-event flipper_install --argument-names plugin
141141
# Set universal variables, create bindings, and other initialization logic.
142142
end
143143
144-
function _flipper_update --on-event flipper_update
144+
function _flipper_update --on-event flipper_update --argument-names plugin
145145
# Migrate resources, print warnings, and other update logic.
146146
end
147147
148-
function _flipper_uninstall --on-event flipper_uninstall
148+
function _flipper_uninstall --on-event flipper_uninstall --argument-names plugin
149149
# Erase "private" functions, variables, bindings, and other uninstall logic.
150150
end
151151
```

Diff for: functions/fisher.fish

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
132132

133133
if contains -- "$plugin" $remove_plugins
134134
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
135-
emit {$name}_uninstall
135+
emit {$name}_uninstall $plugin
136136
end
137137
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
138138
set --erase _fisher_plugins[$index]
@@ -188,7 +188,7 @@ function fisher --argument-names cmd --description "A plugin manager for Fish"
188188
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~)
189189
source $file
190190
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
191-
emit {$name}_$event
191+
emit {$name}_$event $plugin
192192
end
193193
end
194194
end

0 commit comments

Comments
 (0)