mirror of
https://github.com/nushell/nushell.git
synced 2025-06-20 09:58:15 +02:00
register-plugin.nu: refactor register plugin (#6409)
This commit is contained in:
parent
7b07e976b8
commit
7b502a4c7f
@ -3,19 +3,24 @@ def match [input, matchers: record] {
|
|||||||
echo $matchers | get $input | do $in
|
echo $matchers | get $input | do $in
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# register plugin
|
||||||
|
def register_plugin [encoding, plugin] {
|
||||||
|
print $"registering ($plugin)"
|
||||||
|
nu -c $'register -e ($encoding) ($plugin)'
|
||||||
|
}
|
||||||
|
|
||||||
# get list of all plugin files from their installed directory
|
# get list of all plugin files from their installed directory
|
||||||
let plugin_location = ((which nu).path.0 | path dirname)
|
let plugin_location = ((which nu).path.0 | path dirname)
|
||||||
|
|
||||||
# for each plugin file, print the name and launch another instance of nushell to register it
|
# for each plugin file, print the name and launch another instance of nushell to register it
|
||||||
for plugin in (ls $"($plugin_location)/nu_plugin_*") {
|
for plugin in (ls $"($plugin_location)/nu_plugin_*") {
|
||||||
print $"registering ($plugin.name)"
|
|
||||||
match ($plugin.name | path basename | str replace '\.exe$' '') {
|
match ($plugin.name | path basename | str replace '\.exe$' '') {
|
||||||
nu_plugin_custom_values: { nu -c $'register -e msgpack ($plugin.name)' }
|
nu_plugin_custom_values: { register_plugin msgpack $plugin.name }
|
||||||
nu_plugin_example: { nu -c $'register -e msgpack ($plugin.name)' }
|
nu_plugin_example: { register_plugin msgpack $plugin.name }
|
||||||
nu_plugin_from_parquet: { nu -c $'register -e json ($plugin.name)' }
|
nu_plugin_from_parquet: { register_plugin json $plugin.name }
|
||||||
nu_plugin_gstat: { nu -c $'register -e msgpack ($plugin.name)' }
|
nu_plugin_gstat: { register_plugin msgpack $plugin.name }
|
||||||
nu_plugin_inc: { nu -c $'register -e json ($plugin.name)' }
|
nu_plugin_inc: { register_plugin json $plugin.name }
|
||||||
nu_plugin_query: { nu -c $'register -e json ($plugin.name)' }
|
nu_plugin_query: { register_plugin json $plugin.name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user