#!/bin/bash

# Regen Commands Handler
# Front door to lpRegen — rebuilds generated data whose sources changed.

cliHandleRegenCommands()
{
    local scope="${initial_command2:-all}"
    local opt="$initial_command3"

    # Allow `regen --force` (force in the scope slot) as well as `regen all --force`.
    local force=""
    if [[ "$scope" == "--force" || "$scope" == "force" || "$scope" == "-f" ]]; then
        force="--force"; scope="all"
    fi
    [[ "$opt" == "--force" || "$opt" == "force" || "$opt" == "-f" ]] && force="--force"

    case "$scope" in
        all|webui|arrays)
            lpRegen "$scope" $force
            ;;
        help|"")
            cliShowRegenHelp
            ;;
        *)
            isNotice "Invalid regen scope: $scope"
            cliShowRegenHelp
            ;;
    esac
}
