#!/bin/bash

# Help Commands Handler
# Handles all help subcommands

cliHandleHelpCommands()
{
    local category="$initial_command2"
    
    if [[ -z "$category" ]]; then
        # Show main help - list all available commands
        echo ""
        echo "Available Commands:"
        echo ""
        echo "  libreportal run                          - Run the LibrePortal control panel"
        echo "  libreportal install [type]               - Install LibrePortal software"
        echo "  libreportal update                       - Updates LibrePortal to the latest version"
        echo "  libreportal reset                        - Reinstall LibrePortal install files"
        echo "  libreportal app [action] [name]          - Manage apps in LibrePortal"
        echo "  libreportal system [action]              - System operations"
        echo "  libreportal validation [action]          - Configuration validation"
        echo "  libreportal dockertype [type]            - Set the Docker type"
        echo "  libreportal restore [type] [action]      - Restore LibrePortal backups"
        echo "  libreportal webui [action] [options]     - Manage LibrePortal WebUI"
        echo "  libreportal ip [command] [options]       - IP management system"
        echo ""
        echo "Use 'libreportal help [category]' for detailed command lists"
        echo ""
    else
        # Show help for specific category
        local header_file="$install_scripts_dir/cli/commands/$category/cli_${category}_header.sh"
        
        if [[ -f "$header_file" ]]; then
            source "$header_file"
            "cliShow${category^}Help"
        else
            isNotice "Unknown category: ${RED}$category${NC}"
            cliShowHelpHelp;
        fi
    fi
}
