update toolkit register pluginstoolkit add plugins (#12613)

# Description

Updates `toolkit.nu` to use `plugin add`.

There's no need to spawn a separate `nu` to do `register` anymore, since
`plugin add` is not a keyword
This commit is contained in:
Devyn Cairns 2024-04-21 16:23:12 -07:00 committed by GitHub
parent 8b7696f4c1
commit aad3ac11da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -410,10 +410,10 @@ def keep-plugin-executables [] {
if (windows?) { where name ends-with '.exe' } else { where name !~ '\.d' } if (windows?) { where name ends-with '.exe' } else { where name !~ '\.d' }
} }
# register all installed plugins # add all installed plugins
export def "register plugins" [] { export def "add plugins" [] {
let plugin_path = (which nu | get path.0 | path dirname) let plugin_path = (which nu | get path.0 | path dirname)
let plugins = (ls $plugin_path | where name =~ nu_plugin | keep-plugin-executables) let plugins = (ls $plugin_path | where name =~ nu_plugin | keep-plugin-executables | get name)
if ($plugins | is-empty) { if ($plugins | is-empty) {
print $"no plugins found in ($plugin_path)..." print $"no plugins found in ($plugin_path)..."
@ -421,12 +421,15 @@ export def "register plugins" [] {
} }
for plugin in $plugins { for plugin in $plugins {
print -n $"registering ($plugin.name), " try {
nu -c $"register '($plugin.name)'" print $"> plugin add ($plugin)"
print "success!" plugin add $plugin
} catch { |err|
print -e $"(ansi rb)Failed to add ($plugin):\n($err.msg)(ansi reset)"
}
} }
print "\nplugins registered, please restart nushell" print $"\n(ansi gb)plugins registered, please restart nushell(ansi reset)"
} }
def compute-coverage [] { def compute-coverage [] {