# shellcheck shell=dash disable=SC2034

xrc cfgy
___x_cmd_ccal_cfg(){
    [ "$#" -gt 0 ] || {
        ___x_cmd_ccal_init
        return
    }

    local op="$1"; shift
    case "$op" in
        -h|--help)      ___x_cmd help -m ccal --cfg ;;
        *)              ___x_cmd_ccal_cfg___invoke "$op" "$@" ;;
    esac
}

___x_cmd_ccal_cur(){
    local X_help_cmd=; X_help_cmd='___x_cmd help -m ccal --cur' help:arg:parse
    ___x_cmd_ccal_cfg --current "$@"
}


___X_CMD_CCAL_CFG_HIGHLIGHT=""
# "\033[35;1;7m:\033[0m:\033[34;1m:\033[0m"

___x_cmd_ccal_init(){
    local cur_infolunar=""; local cur_infoyiji=""; local cur_wdtitle; local cur_wdstart

    if [ -f "$(___x_cmd_ccal_cur --get config)" ]; then
        ___x_cmd_ccal_cur cur_infolunar:=infolunar cur_infoyiji:=infoyiji cur_wdtitle:=wdtitle cur_wdstart:=wdstart 2>/dev/null
    fi

    # ccal:info --hint 'x ccal cc' "You can customize country code as 'auto' or cn or 'be+fr'. Use 'x ccal cc' to show all supported country code."
    ___x_cmd_ccal_cfg___invoke --init  \
        infolunar   "Whether to display lunar calendar information"                 \
                    "${cur_infolunar:-enable}"      '=' enable disable --           \
        infoyiji    "Whether to display auspicious and inauspicious information"    \
                    "${cur_infoyiji:-enable}"       '=' enable disable --           \
        wdtitle     "Set up the week headers"                                       \
                    "${cur_wdtitle:-zhou}"          '=' zhou en xingqi libai yao -- \
        wdstart     "Set up the first day of the week"                              \
                    "${cur_wdstart:-0}"             '=' 0 1 2 3 4 5 6
        # highlight   "Default highlight code (optional)"                         \
        #             "${cur_highlight:-"$___X_CMD_CCAL_CFG_HIGHLIGHT"}"
}


___X_CMD_CCAL_CFG_VARLIST="infolunar,infoyiji,wdtitle,wdstart"
___x_cmd_ccal_cfg___invoke(){
    ___x_cmd_cfgy_obj                                               \
        --prefix            ___X_CMD_CCAL_CFG_DATA                \
        --default-config    "${___X_CMD_ROOT_CFG}/ccal/X.cfg.yml" \
        --current-config    "${___X_CMD_CCAL_LOCAL_CONFIG}"       \
        --current-profile   "${___X_CMD_CCAL_LOCAL_PROFILE}"      \
        --varlist           "$___X_CMD_CCAL_CFG_VARLIST"          \
        "$@"
}

