Two faults in the same dispatch branch. The unknown-command path called handleHelpCommands, which has never existed — the function is cliHandleHelpCommands. So every unrecognised verb printed "Unknown command" and then died on `handleHelpCommands: command not found`, withholding the help that was the entire purpose of the branch. Routing is the category DIRECTORY name, which is not always the word that comes to hand: `libreportal validate system` is what people type, and it fell into that same broken branch while the working spelling was `validation`. Map the synonym onto its directory rather than renaming the directory, so the handler name derived from it still resolves. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
61 lines
2.3 KiB
Bash
Executable File
61 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cliInitialize()
|
|
{
|
|
cliUpdateCommands;
|
|
|
|
# Many commands shell out via `sudo -u "$docker_install_user"` (backup
|
|
# engines, permission fixes, file copies). Resolve it up front so commands
|
|
# run from the WebUI — e.g. `setup finalize`, `backup` — get a valid user
|
|
# instead of an empty one. The app category still runs the fuller
|
|
# checkInstallTypeRequirement below.
|
|
resolveDockerInstallUser;
|
|
|
|
# Dynamic routing - auto-discover ALL categories!
|
|
local category="$initial_command1"
|
|
|
|
# Handle empty command as help
|
|
if [[ -z "$category" ]]; then
|
|
category="help"
|
|
fi
|
|
|
|
# Verb aliases. Routing is the category DIRECTORY name, which is not always
|
|
# the word that comes to hand — `libreportal validate system` is what people
|
|
# type, and it failed as an unknown command while the working spelling was
|
|
# `validation`. Map the synonym onto its directory rather than renaming the
|
|
# directory, so the handler name derived below still matches.
|
|
case "$category" in
|
|
validate) category="validation" ;;
|
|
esac
|
|
|
|
local commands_file="$install_scripts_dir/cli/commands/$category/cli_${category}_commands.sh"
|
|
local header_file="$install_scripts_dir/cli/commands/$category/cli_${category}_header.sh"
|
|
|
|
# Check if both header and commands files exist
|
|
if [[ -f "$commands_file" && -f "$header_file" ]]; then
|
|
# Special handling for app category
|
|
if [[ "$category" == "app" ]]; then
|
|
checkInstallTypeRequirement;
|
|
fi
|
|
|
|
# Source the commands file
|
|
source "$commands_file"
|
|
|
|
# Call the handler function
|
|
"cliHandle${category^}Commands"
|
|
else
|
|
isNotice "Unknown command: ${RED}$category${NC}"
|
|
|
|
# Show help if command not found
|
|
local help_commands_file="$install_scripts_dir/cli/commands/help/cli_help_commands.sh"
|
|
if [[ -f "$help_commands_file" ]]; then
|
|
source "$help_commands_file"
|
|
# cliHandleHelpCommands, not handleHelpCommands — the latter has never
|
|
# existed, so every unrecognised verb printed "Unknown command" and
|
|
# then died on `handleHelpCommands: command not found` instead of
|
|
# showing the help that was the whole point of this branch.
|
|
cliHandleHelpCommands
|
|
fi
|
|
fi
|
|
}
|