# shellcheck shell=dash

___x_cmd_lsio_readme(){
    [ "$#" -gt 0 ] || N=lsio M="Provide a image name" log:ret:1

    local op="$1"; shift
    case "$op" in
        -h|--help)
            ___x_cmd help -m lsio readme;        return ;;
        --app)
            ___x_cmd_lsio_readme___app             "$@" ;;
        --raw)
            ___x_cmd_lsio_readme___raw             "$@" ;;
        *)  ___x_cmd_lsio_readme___app "$op"       "$@" ;;
    esac
}

___x_cmd_lsio_readme___raw(){
    local name="$1"; [ -n "$name" ] || N=lsio M="Provide a image name" log:ret:1
    ___x_cmd ccmd 1d -- ___x_cmd curl "https://raw.githubusercontent.com/linuxserver/docker-${name}/master/README.md"
}

___x_cmd_lsio_readme___app(){
    if ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_manual; then
        ___x_cmd_lsio_readme___raw "$@" | ___x_cmd glow -p
    else
        ___x_cmd_lsio_readme___raw "$@"
    fi
}
