# shellcheck shell=dash disable=1090
___x_cmd_zshplugin___main(){
    [ "$#" -gt 0 ] ||   set -- info

    local op="$1"; shift
    case "$op" in
        info|load|hasload)
            ___x_cmd_zshplugin___"$op"     "$@" ;;
        -h|--help)
            x help -m zshplugin "$@"; return    ;;
    esac
}

# in the future, using lazyload
___x_cmd_zshplugin___load(){
    [ -n "$ZSH_VERSION" ] || N=zshplugin M='Only supported in zsh environment' log:ret:1
    [ $# -gt 0 ] || set -- zsh-syntax-highlighting zsh-autosuggestions zsh-config
    ___x_cmd_zshplugin___load_inner "$@"
}

___x_cmd_zshplugin___load_inner(){
    while [ $# -gt 0 ]; do
        [ -d "$___X_CMD_ROOT_MOD/zshplugin/lib/thirdparty/$1" ] || N=zshplugin M="Not support zsh-plugin[$1]" log:ret:1
        ___x_cmd_zshplugin___hasload "$1" || {
            . "$___X_CMD_ROOT_MOD/zshplugin/lib/thirdparty/$1/$1.zsh"
            ___X_CMD_ZSHPLUGIN_LOADED="${___X_CMD_ZSHPLUGIN_LOADED} ${1}"
        }
        shift
    done
}

___x_cmd_zshplugin___hasload(){
    [ $# -gt 0 ] || {
        [ -n "$___X_CMD_ZSHPLUGIN_LOADED" ]
        return
    }

    local data="${___X_CMD_ZSHPLUGIN_LOADED} "
    [ "${data#* "$1" }" != "$data" ]
}

___x_cmd_zshplugin___info(){
    printf "%s\n" "zshplugin available:
  - zsh-syntax-highlighting: Adds syntax highlighting to the command line, making it easier to distinguish valid and invalid commands.
  - zsh-autosuggestions: Provides real-time command suggestions based on history, improving typing efficiency.
  - zsh-config: Helps manage and customize zsh configurations, making it easier to set up your shell environment."

}
