# Lazy Configuration Loader # Dynamically loads full loader.nu only when needed # Provides fast-path for help and status commands use ./loader-minimal.nu * # Load full configuration loader (lazy-loaded on demand) # Used by commands that actually need to parse config def load-full-loader [] { # Import the full loader only when needed use ../config/loader.nu * } # Smart config loader that checks if full config is needed # Returns minimal config for fast commands, full config for others export def get-config-smart [ --command: string = "" # Current command being executed --debug = false --validate = true --environment: string ] { # Fast-path for help and status commands (don't need full config) let is_fast_command = ( $command == "help" or $command == "status" or $command == "version" or $command == "workspace" and ($command | str contains "list") ) if $is_fast_command { # Return minimal config for fast operations return (get-minimal-config --debug=$debug --environment=$environment) } # For all other commands, load full configuration load-full-loader # This would call the full loader here, but since we're keeping loader.nu, # just return a marker that full config is needed "FULL_CONFIG_NEEDED" } # Get minimal configuration for fast operations # Only includes workspace and environment detection def get-minimal-config [ --debug = false --environment: string ] { let current_environment = if ($environment | is-not-empty) { $environment } else { detect-current-environment } let active_workspace = (get-active-workspace) # Return minimal config record { workspace: $active_workspace environment: $current_environment debug: $debug paths: { base: if ($active_workspace | is-not-empty) { $active_workspace.path } else { "" } } } } # Check if a command needs full config loading export def command-needs-full-config [command: string]: nothing -> bool { let fast_commands = [ "help", "version", "status", "workspace list", "workspace active", "plugin list", "env", "nu" ] not ($command in $fast_commands or ($command | str contains "help")) }