hn

command module
v0.0.0-...-83d7e21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

README

A simple commandline hacker news client.

Features:

  • Browse the front page anonymously (i.e. no login) and sort by new, hot, best
  • Search for stories via the Algolia API and sort by date, popularity
  • Format output for plain or terminal markdown viewing (via e.g. mdcat)
    • Markdown via mdcat et al only possible on supported terminals (e.g. kitty, iTerm2)
  • Format output in json or csv for scripting
    • See here for details on the Item schema

Examples:

  • Get top 30 stories on the front page:

    hn
    
  • Get newest 50 stories on the front page and output as markdown using mdcat:

    hn --ranking new --limit 50 --style markdown | mdcat
    
  • Search for stories containing "foobar" ranked by date and output as json:

    hn --query "foobar" --ranking date --style json
    

Full CLI:

Options:
    -h, --help      show this help message and exit
    -v, --version   show program version information and exit
    -l, --limit     max number of results to fetch (default: 30)
    -s, --style     output style, one of plain, markdown, md, json, csv (default: plain)
    -r, --ranking   ranking method
                        one of top, new, best for front page items (default: top)
                        one of date, popularity for search result items (default: popularity)
    -q, --query     search query
    -t, --tags      filter search results on specific tags (default: story)

Notes:
    The csv output columns (and json field names) are:

    id,deleted,type,by,time,text,dead,parent,poll,kids,url,score,title,parts,descendents

    See https://github.com/HackerNews/API for schema details.

    Search tags are ANDed by default but can be ORed if between parentheses. For
    example, "author_pg,(story,poll)" filters on "author_pg AND (type=story OR type=poll)".
    See https://hn.algolia.com/api for more.

This code is licensed under the GNU General Public License version 3.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
src
api
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL