# shellcheck shell=dash
xrc docker
___x_cmd log init webtop

___X_CMD_WEBTOP_HOME_DIR="$___X_CMD_ROOT_DATA/webtop/home"

xrc:mod:lib     webtop        ls open all cfg container/_index image/_index home/_index

___x_cmd_webtop___main(){
    [ "$#" -gt 0 ] ||   set --  ps

    local op="$1"; shift
    case "$op" in
        id|start|run|ps|images|rm|bash|\
        pause|unpause|stop|restart)
                        ___x_cmd_webtop_container "$op" "$@" ;;

        c|container)
                        ___x_cmd_webtop_container       "$@" ;;

        img|image)      ___x_cmd_webtop_image           "$@" ;;
        o|open)         ___x_cmd_webtop_open            "$@" ;;
        ls|la|fz)       ___x_cmd_webtop_"$op"           "$@" ;;

        home)           ___x_cmd_webtop_home            "$@" ;;

        all)            ___x_cmd_webtop_all             "$@" ;;

        cfg|--cfg)      ___x_cmd_webtop_cfg             "$@" ;;
        cur|--cur)      ___x_cmd_webtop_cur             "$@" ;;
        init|--init)    ___x_cmd_webtop_init            "$@" ;;
        -h|--help)      ___x_cmd help -m webtop         "$@" ;;

        *)              N=webtop M="Unsupport subcmd -> $op" log:ret:64 ;;
    esac
}

___x_cmd_webtop_images(){
    ___X_CMD_DOCKER_IMAGE_PREFIX=${___X_CMD_WEBTOP_URL_PREFIX}/webtop \
        ___x_cmd docker images "$@"
}

___x_cmd_webtop_fz(){
    ___X_CMD_DOCKER_PS_PREFIX="x-webtop-"        \
    ___X_CMD_DOCKER_IMAGE_PREFIX="linuxserver/webtop"     \
        ___x_cmd docker fz  "$@"
}
