
# config : startup ...
# config : using neo, or using fast fetch
# config : tmux disable
# config : vscode/editor environment disable
# config : screen disable
# config : ssh-upper ? level -> using all ? To ensure all information fetch .


# shellcheck shell=dash disable=SC2034

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

    local op="$1"; shift
    case "$op" in
        -h|--help)      ___x_cmd help -m neo --cfg ;;
        *=*)            ___x_cmd_neo_cfg___invoke "$op" "$@"
                        ;;
        def_)           ___x_cmd_neo_def_ "$@" ;;
        *)              ___x_cmd_neo_cfg___invoke "$op" "$@" ;;
    esac
}

___x_cmd_neo_def_(){
    local op="$1";
    case "$op" in
        startup)        x_="$___X_CMD_NEO_DEFAULT_STARTUP" ;;
        tmux)           x_="$___X_CMD_NEO_DEFAULT_TMUX" ;;
        sshroot)        x_="$___X_CMD_NEO_DEFAULT_SSHROOT" ;;
        *) ;;
    esac
}

___x_cmd_neo_cur(){
    local X_help_cmd=; X_help_cmd='___x_cmd help -m neo --cur' help:arg:parse
    ___x_cmd_neo_cfg --current "$@"
}

___x_cmd_neo_init(){
    local cur_startup=; local cur_tmux=; local cur_sshroot=

    if [ -f "$(___x_cmd_neo_cur --get config)" ]; then
        ___x_cmd_neo_cur cur_startup:=startup cur_tmux:=tmux cur_sshroot:=sshroot 2>/dev/null
    fi

    ___x_cmd_neo_cfg___invoke --init ${cur_apikey:+"--ctrl_exit_strategy"}      \
        startup     "startup"                                                   \
                    "${cur_startup:-no}"   '=' no fastfetch mini std all  --    \
        tmux        "Enable fetch in tmux"                                      \
                    "${cur_tmux:-no}"      '=' no fastfetch mini std all  --    \
        sshroot     "ssh fetch mode"                                            \
                    "${cur_sshroot:-mini}" '=' no fastfetch mini std all

    ___x_cmd_neo_cur cur_startup:=startup 2>/dev/null

    if [ "$cur_startup" != no ]; then
        ___x_cmd fprintf "$___X_CMD_ROOT_DATA/neo/boot" "%s\n" "$cur_startup"
    else
        ___x_cmd rmrf "$___X_CMD_ROOT_DATA/neo/boot"
    fi
}


___X_CMD_NEO_CFG_VARLIST="startup,tmux,sshroot"
___x_cmd_neo_cfg___invoke(){
    ___x_cmd_cfgy_obj   \
        --prefix            ___X_CMD_NEO_CFG_DATA                \
        --default-config    "${___X_CMD_ROOT_CFG}/neo/X.cfg.yml" \
        --current-config    "${___X_CMD_NEO_LOCAL_CONFIG}"       \
        --current-profile   "${___X_CMD_NEO_LOCAL_PROFILE}"      \
        --varlist           "$___X_CMD_NEO_CFG_VARLIST"          \
        "$@"
}


