# shellcheck shell=dash

___X_CMD_WEBTOP_URL_PREFIX="linuxserver"    # lscr.io/linuxserver

xrc:mod:lib     webtop  image/refit image/pull image/id image/rm

___x_cmd_webtop_image(){
    [ $# -gt 0 ] ||     set -- ls

    local op="$1";      shift
    case "$op" in
        -h|--help)
            ___x_cmd help -m webtop image   "$@" ;;

        pull|refit|ls|rm)
            ___x_cmd_webtop_image_"$op"     "$@" ;;
        *)
            N=webtop M="Unknwon op -> $op" log:ret:64
            ;;
    esac
}

___x_cmd_webtop_image_ls(){
    ___x_cmd_webtop_images "$@"
}

___x_cmd_webtop_image_tag_normal_(){
    local image="$1"
    x_="$image"
    case "$image" in
        *-*-*)  return 1 ;;
        *-*)
                local release="${image%-*}"
                local desktop="${image#*-}"

                case "$release" in
                    alpine|arch|debian|ubuntu|fedora|rocky) ;;
                    *)  return 1
                esac

                case "$desktop" in
                    i3|mate|icewm|openbox|xfce|kde)  ;;
                    *)  return 1
                esac
                ;;

        el)     x_="${image}-xfce"
                ;;
        alpine) x_="${image}-mate" ;;
        arch|debian|ubuntu|fedora|rocky)
                x_="${image}-kde"
                # webtop:info "Using default desktop -> ${default_desktop}"
                ;;

        *)
                return 1 ;;

    esac
}
