# Tools Module - Development Tools and Utilities # Commands for development utilities, plugin management, and system tools # ๐Ÿ” VERSION AND VALIDATION COMMANDS # Check nushell version consistency [no-cd] validate-nushell: @echo "๐Ÿ” Validating nushell version consistency..." @{{justfile_directory()}}/scripts/run.sh --check-only # Fix nushell version mismatches [no-cd] fix-nushell: @echo "๐Ÿ”ง Fixing nushell version mismatches..." @{{justfile_directory()}}/scripts/run.sh --fix --check-only # Update nu dependency versions [no-cd] update-nu-versions: @echo "๐Ÿ”„ Updating nu dependency versions..." @{{justfile_directory()}}/scripts/run.sh update_nu_versions.nu # List current nu dependency versions [no-cd] list-nu-versions: @echo "๐Ÿ“‹ Current nu dependency versions:" @{{justfile_directory()}}/scripts/run.sh update_nu_versions.nu list # Update nushell submodule [no-cd] update-nushell: @echo "๐Ÿ”„ Updating nushell submodule..." @bash {{justfile_directory()}}/scripts/sh/update_nushell.sh update # ๐Ÿ†• PLUGIN MANAGEMENT COMMANDS # Create a new plugin from template [no-cd] make-plugin PLUGIN_NAME: @echo "๐Ÿ†• Creating new plugin: {{PLUGIN_NAME}}" @{{justfile_directory()}}/scripts/run.sh make_plugin.nu {{PLUGIN_NAME}} # Install specific plugin locally [no-cd] install-plugin PLUGIN: @echo "๐Ÿ“ฅ Installing {{PLUGIN}} locally..." @cd {{PLUGIN}} && cargo build --release @echo "To add to nushell: plugin add ./{{PLUGIN}}/target/release/{{PLUGIN}}" # Remove plugin from workspace [no-cd] remove-plugin PLUGIN: @echo "๐Ÿ—‘๏ธ Removing plugin {{PLUGIN}}..." @if [ -d "{{PLUGIN}}" ]; then \ echo "Are you sure you want to remove {{PLUGIN}}? (y/N)"; \ read -r confirm; \ if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \ rm -rf "{{PLUGIN}}"; \ echo "โœ… Removed {{PLUGIN}}"; \ else \ echo "โŒ Cancelled"; \ fi; \ else \ echo "Plugin {{PLUGIN}} not found"; \ fi # List all plugins [no-cd] list-plugins: @echo "๐Ÿ“‹ Available plugins:" @for plugin in nu_plugin_*; do \ if [ -d "$$plugin" ]; then \ echo " - $$plugin"; \ fi; \ done # Show plugin information [no-cd] plugin-info PLUGIN: @echo "โ„น๏ธ Plugin Information: {{PLUGIN}}" @if [ -d "{{PLUGIN}}" ]; then \ echo "Name: {{PLUGIN}}"; \ echo "Path: $(pwd)/{{PLUGIN}}"; \ if [ -f "{{PLUGIN}}/Cargo.toml" ]; then \ echo "Version: $(grep '^version' {{PLUGIN}}/Cargo.toml | cut -d'"' -f2)"; \ echo "Description: $(grep '^description' {{PLUGIN}}/Cargo.toml | cut -d'"' -f2 || echo 'Not available')"; \ fi; \ echo "Binary exists: $([ -f {{PLUGIN}}/target/release/{{PLUGIN}} ] && echo 'Yes' || echo 'No')"; \ echo "Last modified: $(stat -c %y {{PLUGIN}} 2>/dev/null || stat -f %m {{PLUGIN}} 2>/dev/null || echo 'Unknown')"; \ else \ echo "Plugin {{PLUGIN}} not found"; \ fi # ๐Ÿ› ๏ธ DEVELOPMENT TOOLS # Run command on specific plugin plugin PLUGIN CMD: @echo "๐Ÿ”ง Running '{{CMD}}' on {{PLUGIN}}" @cd {{PLUGIN}} && {{CMD}} # Check specific plugin [no-cd] check-plugin PLUGIN: @echo "๐Ÿ” Checking {{PLUGIN}}..." @cd {{PLUGIN}} && cargo check # Watch for changes and rebuild (requires entr) [no-cd] watch PLUGIN: #!/usr/bin/env bash if command -v entr >/dev/null 2>&1; then echo "๐Ÿ‘€ Watching {{PLUGIN}} for changes..." find {{PLUGIN}}/src -name "*.rs" | entr just build-plugin {{PLUGIN}} else echo "โŒ entr not installed. Install with: brew install entr (macOS) or apt install entr (Ubuntu)" fi # Interactive plugin selection (requires fzf) [no-cd] interactive: #!/usr/bin/env bash if command -v fzf >/dev/null 2>&1; then echo "๐ŸŽฏ Interactive Plugin Selection" PLUGIN=$(ls -d nu_plugin_* | fzf --prompt="Select plugin: ") if [ -n "$PLUGIN" ]; then ACTION=$(echo -e "build\ntest\ncheck\nlint\nupstream-check\nupstream-merge\ninstall" | fzf --prompt="Select action: ") if [ -n "$ACTION" ]; then case $ACTION in "upstream-check") just upstream-check-plugin $PLUGIN ;; "upstream-merge") just upstream-merge $PLUGIN ;; "build") just build-plugin $PLUGIN ;; "test") just test-plugin $PLUGIN ;; "check") just check-plugin $PLUGIN ;; "lint") cd $PLUGIN && cargo clippy ;; "install") just install-plugin $PLUGIN ;; esac fi fi else echo "โŒ fzf not installed. Install with: brew install fzf (macOS) or apt install fzf (Ubuntu)" fi # ๐Ÿ“Š SYSTEM INFORMATION # Show environment configuration [no-cd] env-info: @echo "๐ŸŒ Environment Configuration:" @if [ -f env ]; then \ cat env; \ else \ echo "No env file found"; \ fi # Show system information [no-cd] system-info: #!/usr/bin/env bash echo "๐Ÿ’ป System Information:" echo "OS: $(uname -s)" echo "Architecture: $(uname -m)" echo "Nushell: $(nu --version 2>/dev/null || echo 'Not installed')" echo "Rust: $(rustc --version 2>/dev/null || echo 'Not installed')" echo "Cargo: $(cargo --version 2>/dev/null || echo 'Not installed')" echo "Just: $(just --version 2>/dev/null || echo 'Not installed')" echo "Docker: $(docker --version 2>/dev/null || echo 'Not installed')" echo "Git: $(git --version 2>/dev/null || echo 'Not installed')" # Validate setup and dependencies [no-cd] validate: @echo "โœ… Validating setup..." @echo "Checking required tools:" @command -v nu >/dev/null 2>&1 && echo "โœ… nushell" || echo "โŒ nushell (required)" @command -v cargo >/dev/null 2>&1 && echo "โœ… cargo" || echo "โŒ cargo (required)" @command -v git >/dev/null 2>&1 && echo "โœ… git" || echo "โŒ git (required)" @command -v just >/dev/null 2>&1 && echo "โœ… just" || echo "โŒ just (optional but recommended)" @command -v docker >/dev/null 2>&1 && echo "โœ… docker" || echo "โš ๏ธ docker (optional for cross-compilation)" @echo "" @echo "Checking directory structure:" @[ -d scripts ] && echo "โœ… scripts directory" || echo "โŒ scripts directory" @[ -d etc ] && echo "โœ… etc directory" || echo "โŒ etc directory" @[ -f etc/plugin_registry.toml ] && echo "โœ… plugin registry" || echo "โŒ plugin registry" @[ -f etc/upstream_exclude.toml ] && echo "โœ… upstream exclusions" || echo "โš ๏ธ upstream exclusions (optional)" @[ -f env ] && echo "โœ… env file" || echo "โš ๏ธ env file (optional)" @echo "" @echo "Plugin directories:" @ls -d nu_plugin_* 2>/dev/null | wc -l | xargs echo "๐Ÿ“ฆ Found plugins:" # ๐Ÿงน CLEANUP COMMANDS # Clean all build artifacts [no-cd] clean: #!/usr/bin/env bash echo "๐Ÿงน Cleaning build artifacts..." # Clean plugin target directories for plugin in nu_plugin_*; do if [ -d "$plugin/target" ]; then echo "Removing $plugin/target..." rm -rf "$plugin/target" fi done # Clean API plugin target directories for plugin in api_nu_plugin_*; do if [ -d "$plugin/target" ]; then echo "Removing $plugin/target..." rm -rf "$plugin/target" fi done # Clean wrks subdirectory targets if [ -d "wrks" ]; then for plugin in wrks/nu_plugin_*; do if [ -d "$plugin/target" ]; then echo "Removing $plugin/target..." rm -rf "$plugin/target" fi done fi # Also clean nushell submodule if it exists (use cargo clean for complex projects) if [ -d "nushell" ]; then echo "Cleaning nushell submodule..." cd nushell && cargo clean && cd .. fi # Clean specific plugin [no-cd] clean-plugin PLUGIN: @echo "๐Ÿงน Cleaning {{PLUGIN}}..." @if [ -d "{{PLUGIN}}/target" ]; then \ echo "Removing {{PLUGIN}}/target..."; \ rm -rf "{{PLUGIN}}/target"; \ else \ echo "No target directory found for {{PLUGIN}}"; \ fi # Clean distribution files [no-cd] clean-dist: @echo "๐Ÿงน Cleaning distribution files..." @rm -rf distribution @echo "โœ… Cleaned distribution directory" # Clean all caches [no-cd] clean-all: @echo "๐Ÿงน Cleaning everything..." @just clean @just clean-dist @echo "โœ… All clean!" # ๐Ÿ”„ MAINTENANCE COMMANDS # Update all dependencies (careful!) [no-cd] update-deps: @echo "โฌ†๏ธ Updating dependencies (this may break things)..." @for plugin in nu_plugin_*; do \ if [ -d "$$plugin" ]; then \ echo "Updating deps in $$plugin..."; \ cd "$$plugin" && cargo update && cd ..; \ fi; \ done # Fix common issues automatically [no-cd] auto-fix: @echo "๐Ÿ”ง Running automatic fixes..." @just fix-nushell @just fmt @just lint-fix @echo "โœ… Automatic fixes completed" # Generate project statistics [no-cd] stats: @echo "๐Ÿ“Š Project Statistics:" @echo "====================" @echo "Plugins: $(ls -d nu_plugin_* 2>/dev/null | wc -l)" @echo "Rust files: $(find nu_plugin_*/src -name "*.rs" 2>/dev/null | wc -l)" @echo "Lines of code: $(find nu_plugin_*/src -name "*.rs" -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}' || echo '0')" @echo "Test files: $(find nu_plugin_* -name "*test*.rs" -o -name "tests" -type d 2>/dev/null | wc -l)" @echo "Documentation files: $(find . -name "*.md" 2>/dev/null | wc -l)" # ๐Ÿ”ง CONFIGURATION MANAGEMENT # Show configuration files [no-cd] config-list: @echo "๐Ÿ“ Configuration Files:" @echo "======================" @echo "Main configuration:" @[ -f etc/plugin_registry.toml ] && echo "โœ… etc/plugin_registry.toml" || echo "โŒ etc/plugin_registry.toml" @[ -f etc/build_targets.toml ] && echo "โœ… etc/build_targets.toml" || echo "โŒ etc/build_targets.toml" @[ -f etc/upstream_exclude.toml ] && echo "โœ… etc/upstream_exclude.toml" || echo "โš ๏ธ etc/upstream_exclude.toml" @echo "" @echo "Environment:" @[ -f env ] && echo "โœ… env" || echo "โš ๏ธ env (optional)" @echo "" @echo "Build configuration:" @[ -f justfile ] && echo "โœ… justfile" || echo "โŒ justfile" @[ -f Dockerfile.cross ] && echo "โœ… Dockerfile.cross" || echo "โŒ Dockerfile.cross" # Edit configuration file [no-cd] config-edit FILE: @echo "โœ๏ธ Editing configuration: {{FILE}}" @${EDITOR:-nano} {{FILE}} # Backup configuration [no-cd] config-backup: @echo "๐Ÿ’พ Backing up configuration..." @mkdir -p backups/config-$(date +%Y%m%d-%H%M%S) @cp etc/*.toml backups/config-$(date +%Y%m%d-%H%M%S)/ 2>/dev/null || true @[ -f env ] && cp env backups/config-$(date +%Y%m%d-%H%M%S)/ || true @echo "โœ… Configuration backed up to backups/config-$(date +%Y%m%d-%H%M%S)/" # ๐Ÿ“Š TOOLS INFORMATION # Show tools help [no-cd] tools-help: @echo "๐Ÿ› ๏ธ Tools Module Help" @echo "====================" @echo "" @echo "VERSION & VALIDATION:" @echo " validate-nushell - Check nushell version consistency" @echo " fix-nushell - Fix version mismatches" @echo " update-nu-versions - Update nu dependency versions" @echo " list-nu-versions - List current versions" @echo " update-nushell - Update nushell submodule" @echo "" @echo "PLUGIN MANAGEMENT:" @echo " make-plugin NAME - Create new plugin from template" @echo " install-plugin PLUGIN - Install plugin locally" @echo " remove-plugin PLUGIN - Remove plugin from workspace" @echo " list-plugins - List all plugins" @echo " plugin-info PLUGIN - Show plugin information" @echo "" @echo "DEVELOPMENT TOOLS:" @echo " plugin PLUGIN CMD - Run command on plugin" @echo " check-plugin PLUGIN - Check specific plugin" @echo " watch PLUGIN - Watch for changes (requires entr)" @echo " interactive - Interactive plugin selection (requires fzf)" @echo "" @echo "SYSTEM INFORMATION:" @echo " env-info - Show environment configuration" @echo " system-info - Show system information" @echo " validate - Validate setup and dependencies" @echo "" @echo "CLEANUP:" @echo " clean - Clean all build artifacts" @echo " clean-plugin PLUGIN - Clean specific plugin" @echo " clean-dist - Clean distribution files" @echo " clean-all - Clean everything" @echo "" @echo "MAINTENANCE:" @echo " update-deps - Update all dependencies" @echo " auto-fix - Run automatic fixes" @echo " stats - Generate project statistics" @echo "" @echo "CONFIGURATION:" @echo " config-list - Show configuration files" @echo " config-edit FILE - Edit configuration file" @echo " config-backup - Backup configuration" @echo "" @echo "EXAMPLES:" @echo " just make-plugin nu_plugin_myfeature" @echo " just watch nu_plugin_clipboard" @echo " just interactive" @echo " just plugin nu_plugin_image 'cargo bench'"