# shellcheck shell=dash

___x_cmd log init elv

xrc:mod:lib     elv     __binexec   __setup ddgo

___x_cmd_elv___main(){
    [ "$#" -gt 0 ] || {
        ___x_cmd_elv___binexec elvish
        return
    }

    local op="$1"; shift
    case "$op" in
        -h|--help)  ___x_cmd help -m elv                "$@" ;;
        :|ddgo)     ___x_cmd_elv_ddgo                   "$@" ;;
        --sysco)    ___x_cmd_elv___sysco                "$@" ;;

        # --is-setup-required is inner function
        --setup-is-required)
                    ___x_cmd_elv___setup_is_required    "$@" ;;

        setup|--setup)
                    ___x_cmd_elv___setup                "$@" ;;

        # <inner function>
        --binexec)  ___x_cmd_elv___binexec              "$@" ;;
        --|--exec)  ___x_cmd_elv___binexec elvish       "$@" ;;
        # <inner function>

        *)          ___x_cmd_elv___binexec elvish "$op" "$@" ;;
    esac
}

___x_cmd_elv___sysco(){
    ___X_CMD_CO_EXEC_SHELL=elvish ___x_cmd co --exec "$@"
}

___x_cmd_elv___syscoco(){
    ___X_CMD_CO_EXEC_SHELL=elvish ___x_cmd coco --exec "$@"
}
