#!/bin/bash

# Update Commands Handler
# Handles all update subcommands by calling core functions

cliHandleUpdateCommands()
{
    local update_type="$initial_command2"

    case "$update_type" in
        "")
            # Interactive CLI updater (prompts the user).
            checkUpdates
            ;;
        "check")
            # Non-interactive: force a fresh out-of-date check and rewrite
            # update_status.json. Used by the WebUI "Check for updates" action.
            webuiSystemUpdateCheck "force"
            ;;
        "apply"|"now")
            # Non-interactive: perform the update. Used by the WebUI
            # "Update now" action.
            webuiRunUpdate
            ;;
        *)
            isNotice "Invalid update command: ${RED}$update_type${NC}"
            cliShowUpdateHelp
            ;;
    esac
}
