4 releases (2 breaking)

0.3.0 Dec 3, 2021
0.2.0 Nov 28, 2021
0.1.1 Nov 26, 2021
0.1.0 Nov 24, 2021

#830 in Authentication

MIT license

2.5MB
860 lines

hn-cli, a command-line tool to read HackerNews

Crates.io Rust

Screenshots

Installation

You’ll need first to install the Rust toolchain, then: cargo install hn-cli

Usage

List stories (add -p3 or --page 3 to display the third page):

  • Top stories: hn or hn top or hn t
  • New stories: hn new or hn n
  • Best stories: hn best or hn b
  • Show HN stories: hn show or hn s
  • Ask HN stories: hn ask or hn a
  • Job stories: hn job or hn j

After listing stories, note the index of the story you are interested in (let’s suppose it is 5), then:

  • Show story details and comments: hn details 5 or hn d 5
  • Open story link in your browser: hn open 5 or hn o 5

You can also display the details about a user with hn user the_user_name or hn u the_user.

To login, use hn login or hn l. The auth token will be persisted to be used in the next commands. Note that to perform write operations (such as upvoting a story), you will need to reload the list of the stories using the commands listed above, such as hn top.

To logout and remove the persisted auth token, use the command hn logout.

Note: information is obtained by scraping the HackerNews website. The reason this crate does not use the official API is that it does not provide a convenient way to get all the comments for a given story, and only allows read operations.

License

MIT, see LICENSE.

Dependencies

~19–33MB
~449K SLoC