# shellcheck shell=dash

___x_cmd log init termux

xrc:mod:lib     termux      \
                shortcut        prep            \
                sshd    pr      pd/_index       \
                pkg/_index      api/_index      prop

___x_cmd_termux___main(){
    [ "$#" -gt 0 ] ||   set -- --help

    local op="$1"; shift
    case "$op" in
        -h|--help)          ___x_cmd help -m termux             "$@" ;;
        ver|version)        ___x_cmd_termux_version             "$@" ;;
        pp|prop)            ___x_cmd_termux_prop                "$@" ;;

        --prep|prep)        ___x_cmd_termux_prep                "$@" ;;
        cr|change-repo)     ___x_cmd_termux_cr                  "$@" ;;
        shortcut|pkg)       ___x_cmd_termux_"$op"               "$@" ;;

        i|install)          ___x_cmd_termux_pkg install         "$@" ;;

        pr|proot)           ___x_cmd_termux_pr                  "$@" ;;
        pd|proot-distro)
                            ___x_cmd_termux_pd                  "$@" ;;
        prun)               ___x_cmd_termux_pd  run             "$@" ;;

        alp|alpine)         ___x_cmd_termux pd run alpine       "$@" ;;
        arch|archlinux)     ___x_cmd_termux pd run archlinux    "$@" ;;
        deb|debian)         ___x_cmd_termux pd run debian       "$@" ;;
        fed|fedora)         ___x_cmd_termux pd run fedora       "$@" ;;
        ubu|ubuntu)         ___x_cmd_termux pd run ubuntu       "$@" ;;
        suse)               ___x_cmd_termux pd run opensuse     "$@" ;;

        artix|manjaro|pardus|adelie|chimera|deepin|opensuse|rocklinux|void)
                            ___x_cmd_termux pd run "$op"        "$@" ;;

        *)                  ___x_cmd_termux___apimain   "$op"   "$@" ;;
    esac
}

___x_cmd_termux_drun(){
    ___x_cmd docker run --name termux -it "$@" termux/termux-docker
}

___x_cmd_termux_cr(){
    ___x_cmd_cmds termux-change-repo "$@"
}

___x_cmd_termux_version(){
    printf "%s\n" "$TERMUX_VERSION"
}

