

___x_cmd_hn_item___style_pick_(){
    x_=
    local _cmd=
    ___x_cmd_runmode_allow_chatty || N=hn M="Please provide the item [style=browse|link|reader|preview|json|csv]" log:ret:64
    ___x_cmd ui select ,_cmd "Select the item style"         \
        "browse: Open Hacker News comment page"    \
        "link: Open the article link page"         \
        "reader: Using jina to read the article"   \
        "preview: Preview in current terminal"     \
        "json: Output json format"                 \
        "csv: Output csv format" || return $?
    x_="${_cmd%%:*}"
    [ -n "$x_" ]
}

___x_cmd_hn_item(){
    local X_help_cmd="___x_cmd help -m hn item"; help:arg-null:parse
    local op=
    case "$1" in
        --csv|--json|--browse|--link|--preview|--reader)
            op="${1#--}"; shift ;;
    esac

    if [ -z "$op" ]; then
        local x_=; ___x_cmd_hn_item___style_pick_ || return $?
        op="$x_"
    fi

    local id=; for id in "$@"; do
        case "$id" in
            [1-9]*)  ;;
            *)       N=hn M="Please provide the correct item [id=$id]" log:ret:64 ;;
        esac
    done

    case "$op" in
        browse)     ___x_cmd_hn___browse        "$@" ;;
        link)       ___x_cmd_hn___browselink    "$@" ;;
        reader)     ___x_cmd_hn___readerlink    "$@" ;;
        preview)    ___x_cmd_hn___story_data    "$@" | ___x_cmd_hn___story_preview_style ;;
        json)       ___x_cmd_hn___story_data    "$@" | ___x_cmd_hn___story_json_style ;;
        csv)        ___x_cmd_hn___story_data    "$@" | ___x_cmd_hn___story_csv_style ;;
        *)          hn:warn "This display [style=$op] is not supported yet" ;;
    esac
}

