# shellcheck shell=dash disable=2016

___x_cmd_hn___browse(){
    local id; for id in "$@"; do
        local url="https://news.ycombinator.com/item?id=${id}"
        hn:info "Open $url with the browser"
        ___x_cmd browse "$url"
    done
}

___x_cmd_hn___browselink(){
    {
        printf "%s\n" "["
        ___x_cmd_hn___story_data "$@"
        printf "%s\n" "]"
    } | ___x_cmd jo env '*.*' .url -- '
        [ -n "$url" ] || {
            hn:error "No link-git surl for $1"
            return 1
        }
        hn:info "Open item [id=$id] [url=$url] with the browser"
        ___x_cmd browse "$url"
    '
}

___x_cmd_hn___readerlink(){
    {
        printf "%s\n" "["
        ___x_cmd_hn___story_data "$@"
        printf "%s\n" "]"
    } | ___x_cmd jo env '*.*' .url -- '
        [ -n "$url" ] || {
            hn:error "No link-git surl for $1"
            return 1
        }
        ___x_cmd jina reader "$url"
    '
}

