#!/bin/bash

cliHandleConfigCommands()
{
    local action="$initial_command2"

    case "$action" in
        "update")
            local encoded_pairs="$initial_command3"
            if [[ -z "$encoded_pairs" ]]; then
                isError "config update requires the encoded pair string."
                cliShowConfigHelp
            fi
            configUpdateBatch "$encoded_pairs"
            ;;

        "check")
            # Converge live configs on the install templates: copy any missing
            # files / categories (and surface them to the WebUI Config editor
            # via .category), then reconcile the options inside each file —
            # add new keys, drop removed ones, refresh comments, keep the
            # user's values. Read-and-converge; safe to run any time.
            checkConfigFilesMissingFiles
            checkConfigFilesMissingVariables true
            ;;

        "")
            cliShowConfigHelp
            ;;

        *)
            isNotice "Invalid config command: $action"
            cliShowConfigHelp
            ;;
    esac
}
