DEV Community

Kaamkiya
Kaamkiya

Posted on • Updated on

Devcli - A CLI for Dev.to!

Introduction

I made a CLI app for Dev.to! I personally really like terminals, so I decided to make a CLI app so that I can read and reply to Dev articles.

This article was written because of this comment. Thanks @michaeltharrington! 😄

Unfortunately, at the time of this article, the "write an article" feature didn't work, so I had to handwrite this.

What it does

So far, you can use devcli (very unoriginal name, I know) to...

  • read articles (and read the comments, too!)
  • view a list of your followers
  • view the 30 latest articles
  • display information about a user
  • see the tags that you follow
  • view your reading list

If you have any new feature ideas, you can comment on this article or open an issue in the repo 😀

Using devcli

You can install it by following the instructions for your platform in the install guide, or just type the command below:

go install github.com/Kaamkiya/devcli
Enter fullscreen mode Exit fullscreen mode

Beware that the command above requires Go. If you only want the binary for your platform, follow the instructions.

Make sure the binary is in your $PATH variable.

You can add it like this:

export PATH="$PATH:$(go env GOPATH)" # if you used Go to install
export PATH="$PATH:/path/to/download" # if you installed the platform-specific binary
Enter fullscreen mode Exit fullscreen mode

Now, if you really want, you can read this article from the terminal 😄

devcli read kaamkiya/devcli-a-cli-for-devto-5gcb
Enter fullscreen mode Exit fullscreen mode

Otherwise, keep going!

API Keys and user-specific commands

Some commands require an API key. Here's how to get one:

Go to the extensions page of dev.to.

Scroll until you see this:

API Keys

It should be somewhere near the bottom.

Enter a name for your API key. I recommend using devcli auth, because that way you know what the key is used for.

Press the big blue "Generate API key" button.

Scroll all the way back down, and click on the dropdown that says the name of your API key.

API key dropdown

Copy the key. It will be a long string of random characters.

Go to your terminal and type the following:

export DEV_API_KEY="whatever_you_copy_pasted"
Enter fullscreen mode Exit fullscreen mode

NOTE: Never share your API keys!

Now you can run all of the commands. To check if it worked, try devcli readinglist.

If it worked, your reading list has now been printed!

Cheat sheet

Here's a quick cheat sheet of the currently available commands:

devcli read $article_id # read an article by ID
devcli read $author/$article_slug # read an article by author/slug

devcli user $username # display info about a user

devcli following-tags # requires an API key

devcli followers # requires an API key

devcli readinglist # requires an API key

devcli latest # print a list of the 30 most recent articles

devcli help # print a help message

# examples:
devcli read 1690174
devcli read 1690174 --show-comments # display the top-level comments as well
devcli user ben # show stuff about @ben
Enter fullscreen mode Exit fullscreen mode

Feel free to contribute or try it out 😄

Let me know what you think!

Any new feature ideas? Feedback? I'd love to see what you think!

EDIT: Moved to Codeberg.

Top comments (2)

Collapse
 
michaeltharrington profile image
Michael Tharrington

This is so cool, Kaamkiya! Really appreciate ya sharing. 🙌

Collapse
 
michaeltharrington profile image
Michael Tharrington

I actually missed the shoutout you gave me the first time I read through. That was super kind of ya! Thanks a bunch. 😀

Some comments may only be visible to logged-in visitors. Sign in to view all comments.