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 |
#933 in Authentication
2.5MB
860 lines
hn-cli
, a command-line tool to read HackerNews
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
orhn top
orhn t
- New stories:
hn new
orhn n
- Best stories:
hn best
orhn b
- Show HN stories:
hn show
orhn s
- Ask HN stories:
hn ask
orhn a
- Job stories:
hn job
orhn 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
orhn d 5
- Open story link in your browser:
hn open 5
orhn 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
~22–36MB
~477K SLoC