chore: use script to register plugins in nushell
This commit is contained in:
parent
187a69575c
commit
8dee8b776e
@ -259,6 +259,9 @@ def main [
|
|||||||
--plugins (-p): list<string> = [] # Specific plugins to install
|
--plugins (-p): list<string> = [] # Specific plugins to install
|
||||||
--list (-l) # List available plugins
|
--list (-l) # List available plugins
|
||||||
--dry-run (-d) # Show what would be done
|
--dry-run (-d) # Show what would be done
|
||||||
|
--register-only (-r) # Only register plugins, don't copy binaries
|
||||||
|
--no-register # Copy binaries but don't register with nushell
|
||||||
|
--verify (-v) # Verify plugin registration after installation
|
||||||
] {
|
] {
|
||||||
let available_plugins = ls | where type == file and name =~ \"nu_plugin_\" | get name
|
let available_plugins = ls | where type == file and name =~ \"nu_plugin_\" | get name
|
||||||
|
|
||||||
@ -281,8 +284,11 @@ def main [
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
print " + '$"🚀 Installing ($plugins_to_install | length) plugins to ($bin_path)..."' + "
|
print " + '$"🚀 Processing ($plugins_to_install | length) plugins..."' + "
|
||||||
|
|
||||||
|
# Step 1: Copy binaries (unless register-only mode)
|
||||||
|
if not " + '$register_only' + " {
|
||||||
|
print " + '$"\\n📦 Installing binaries to ($bin_path)..."' + "
|
||||||
for plugin in " + '$plugins_to_install' + " {
|
for plugin in " + '$plugins_to_install' + " {
|
||||||
if " + '$dry_run' + " {
|
if " + '$dry_run' + " {
|
||||||
print " + '$"Would install: ($plugin) → ($bin_path)/($plugin)"' + "
|
print " + '$"Would install: ($plugin) → ($bin_path)/($plugin)"' + "
|
||||||
@ -296,9 +302,71 @@ def main [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 2: Register plugins with nushell (unless disabled)
|
||||||
|
if not " + '$no_register' + " {
|
||||||
|
print \"\\n🔌 Registering plugins with nushell...\"
|
||||||
|
for plugin in " + '$plugins_to_install' + " {
|
||||||
|
let plugin_path = if " + '$register_only' + " {
|
||||||
|
# Use current directory path for register-only mode
|
||||||
|
" + '$"./($plugin)"' + "
|
||||||
|
} else {
|
||||||
|
# Use installation path for normal mode
|
||||||
|
" + '$"($bin_path)/($plugin)"' + "
|
||||||
|
}
|
||||||
|
|
||||||
|
if " + '$dry_run' + " {
|
||||||
|
print " + '$"Would register: plugin add ($plugin_path)"' + "
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
nu -c " + '$"plugin add ($plugin_path)"' + "
|
||||||
|
print " + '$" ✅ Registered ($plugin)"' + "
|
||||||
|
} catch {|err|
|
||||||
|
print " + '$" ⚠️ Failed to register ($plugin): ($err.msg)"' + "
|
||||||
|
print " + '$" You can manually register with: plugin add ($plugin_path)"' + "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 3: Verify plugin registration (if requested and plugins were registered)
|
||||||
|
if " + '$verify' + " and not " + '$no_register' + " and not " + '$dry_run' + " {
|
||||||
|
print \"\\n🔍 Verifying plugin registration...\"
|
||||||
|
for plugin in " + '$plugins_to_install' + " {
|
||||||
|
let plugin_name = (" + '$plugin' + " | str replace \"nu_plugin_\" \"\")
|
||||||
|
try {
|
||||||
|
let found = (nu -c " + '$"plugin list | where name =~ ($plugin_name) | length"' + " | into int)
|
||||||
|
if " + '$found' + " > 0 {
|
||||||
|
print " + '$" ✅ Verified ($plugin)"' + "
|
||||||
|
} else {
|
||||||
|
print " + '$" ❌ Not found in plugin list: ($plugin)"' + "
|
||||||
|
}
|
||||||
|
} catch {|err|
|
||||||
|
print " + '$" ⚠️ Could not verify ($plugin): ($err.msg)"' + "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Summary
|
||||||
if not " + '$dry_run' + " {
|
if not " + '$dry_run' + " {
|
||||||
print \"\\n💡 Don't forget to run 'plugin add' for each plugin in nushell!\"
|
if " + '$register_only' + " {
|
||||||
|
print \"\\n✅ Plugin registration completed!\"
|
||||||
|
if " + '$verify' + " {
|
||||||
|
print \"💡 Run 'plugin list' to see all registered plugins\"
|
||||||
|
}
|
||||||
|
} else if " + '$no_register' + " {
|
||||||
|
print \"\\n✅ Plugin installation completed!\"
|
||||||
|
print \"💡 To register plugins, run: nu install_nu_plugins.nu --register-only\"
|
||||||
|
} else {
|
||||||
|
print \"\\n✅ Plugin installation and registration completed!\"
|
||||||
|
if " + '$verify' + " {
|
||||||
|
print \"💡 All plugins verified. Run 'plugin list' to see details\"
|
||||||
|
} else {
|
||||||
|
print \"💡 Restart nushell or run 'plugin list' to see registered plugins\"
|
||||||
|
print \" Add --verify to automatically check registration next time\"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user