From 8dee8b776e570dc1e62678866e81aa448d0ebede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Pe=CC=81rez?= Date: Sat, 20 Sep 2025 20:14:02 +0100 Subject: [PATCH] chore: use script to register plugins in nushell --- scripts/collect_install.nu | 92 +++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 12 deletions(-) diff --git a/scripts/collect_install.nu b/scripts/collect_install.nu index d16f497..dcd06d0 100755 --- a/scripts/collect_install.nu +++ b/scripts/collect_install.nu @@ -259,6 +259,9 @@ def main [ --plugins (-p): list = [] # Specific plugins to install --list (-l) # List available plugins --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 @@ -281,24 +284,89 @@ def main [ return } - print " + '$"šŸš€ Installing ($plugins_to_install | length) plugins to ($bin_path)..."' + " + print " + '$"šŸš€ Processing ($plugins_to_install | length) plugins..."' + " - for plugin in " + '$plugins_to_install' + " { - if " + '$dry_run' + " { - print " + '$"Would install: ($plugin) → ($bin_path)/($plugin)"' + " - } else { - try { - cp " + '$plugin' + " " + '$"($bin_path)/($plugin)"' + " - chmod +x " + '$"($bin_path)/($plugin)"' + " - print " + '$" āœ… Installed ($plugin)"' + " - } catch {|err| - print " + '$" āŒ Failed to install ($plugin): ($err.msg)"' + " + # 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' + " { + if " + '$dry_run' + " { + print " + '$"Would install: ($plugin) → ($bin_path)/($plugin)"' + " + } else { + try { + cp " + '$plugin' + " " + '$"($bin_path)/($plugin)"' + " + chmod +x " + '$"($bin_path)/($plugin)"' + " + print " + '$" āœ… Installed ($plugin)"' + " + } catch {|err| + print " + '$" āŒ Failed to install ($plugin): ($err.msg)"' + " + } } } } + # 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' + " { - 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\" + } + } } } "