# shellcheck  shell=dash disable=SC2142,SC2154

alias bwh:arg:local='
    {
        local ___X_CMD_BWH_LOCAL_CONFIG="${___X_CMD_BWH_LOCAL_CONFIG}"
        local ___X_CMD_BWH_LOCAL_PROFILE="${___X_CMD_BWH_LOCAL_PROFILE}"
    } >/dev/null 2>&1
'

alias bwh:arg:config-profile='
    case "$1" in
        --config)
            [ "$#" -gt 0 ] || return 64
            ___X_CMD_BWH_LOCAL_CONFIG="$2"
            shift 2; continue
            ;;

        @*)
            ___X_CMD_BWH_LOCAL_CONFIG="${1#@}"
            shift 1; continue
            ;;

        --profile)
            [ "$#" -gt 0 ] || return 64
            ___X_CMD_BWH_LOCAL_PROFILE="$2"
            shift 2; continue
            ;;

        :*)
            ___X_CMD_BWH_LOCAL_PROFILE="${1#:}"
            shift 1; continue
            ;;
    esac
'


# shellcheck disable=SC2090,SC2142
alias bwh:arg:config-profile-help='
    bwh:arg:local
    local ___X_CMD_ARG_HELP=
    while [ "$#" -gt 0 ]; do
        bwh:arg:config-profile
        case "$1" in
            -h|--help)  ___X_CMD_ARG_HELP=1
        esac
        break
    done
    [ -z "$___X_CMD_ARG_HELP" ] '


alias bwh:arg:help='case "$1" in
        -h|--help)  true    ;;
        *)          false
    esac '

alias bwh:arg:is-not-help='! bwh:arg:help'

alias bwh:arg:judge:display:content:bat='
    if [ "$error" != 0 ]; then N=bwh M="[Error=$error] [Error Msg=$message]" log:ret:1
    else
        if ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_manual ; then
            ___x_cmd_pipevar data x yml j2y | x bat -l yaml
        else
            ___x_cmd_pipevar data
        fi
    fi
'
alias bwh:arg:judge:display:content:yml='
    if [ "$error" != 0 ]; then N=bwh M="[Error=$error] [Error Msg=$message]" log:ret:1
    else
        if ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_manual ; then
            ___x_cmd_pipevar data x yml j2y
        else
            ___x_cmd_pipevar data
        fi
    fi
'

# For example in the subcmd
    # bwh:arg:config-profile-help || {
    #     ___x_cmd_bwh_help sshkey
    #     return 1
    # }

