# What If... Hashnode in the Command Line?

Those who are reading this article would have a bunch of questions or a curiosity to see what this is about. Let's see if I can answer the questions and satisfy your curiosity. Let's roll!

## Why

You may ask ...

![y tho](https://i0.wp.com/blog.meme.com/wp-content/uploads/ytho.png?resize=300%2C300 align="center")

Because why not!? I ditched VSCode and switched to Neovim 3 years ago. So, I've been *living* in the terminal for quite a while. Reading, Editing, Deleting, Moving, Copying files and directories in the command line, and much more (like `grep`, `awk`, `sed`, `curl`, etc.,) have made life easier. So why not just bring Hashnode right into the command line? That brings us to the next question.

## What

### what can it do

Okay, so what can it do? Currently, it supports features like

* Lookup your Profile
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706938546769/42ee5bd9-22bd-483a-b0ad-cd70f31580b9.gif align="center")

* Explore Feed
    
    * Switch Feed Categories
        
* Read Posts
    
* Like Posts
    
* Open them in the browser
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706937836034/28a287a1-f1e5-47a5-a897-abde9085ecda.gif align="center")

* Publish an article
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706938507403/5dec3ca4-fce3-484b-8394-296b6237fd2e.gif align="center")

* But before all that, setting auth token
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706943920311/20d8d64f-33fe-4878-8f03-bf2ab7b5476d.gif align="center")

### what else

For those who think there are only limited features present, the following features are under work

* Write an article in the cli with a live preview
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706938887382/5c3cffb4-01a3-4140-aff7-04e5dac90f7d.gif align="center")

* Comments
    

Hmmm.... but how did I make it? Let's move to that question then.

## How

If you have noticed from the gifs, I typed "golang" in the tags, so yea the cli is made with love, and Golang with awesome packages from Charm and spf13

* **Cobra** - For managing commands and flags
    
* **Viper** - For managing configs
    
* **Bubbletea** - For Interactive CLI features
    
* **Bubbles** - CLI Components
    
* **Lipgloss** - Stying Bubble components
    

Using the `cobra-cli`, I created and registered the necessary commands like

* `auth` - To set the Hashnode token
    
* `me` - To look at profile info
    
* `feed` - To access feed
    
* `publish` - To publish an article
    
* `create` - To write an article
    

Then used `viper` to create a config when auth cmd is used and also to get the token for other commands. Bonded necessary flags of cobra with viper.

Created fetchers for the profile, feed, posts, publish, like and saved them as functions that return the necessary info as a struct that can be used accordingly for the TUI.

Created Bubbletea models for feed, post, publish, and create, making them interactive with Init, Update, View methods.

Added styles to make the view look pretty and readable. Finally building the project to use as a CLI.

> the cli is ***blazingly fast*** btw

## Where

The project is on GitHub. You can access, contribute, and raise issues here. And that answers "where".

%[https://github.com/DhanushAdithya/hashnode-cli] 

## A Little Backstory

When I read about this hackathon, I read that it involves Hashnode APIs and we need to make a project with them. I didn't see the categories in the first place. Started creating this project and I was almost finished with the commands, that's when I reread the categories that had "integrations" and "starter kits". I thought to myself "*this project doesn't fit in any of 'em. lol."* but then I saw "APP IDEAS" listed in the categories and there was "An innovate alternative UI to publish a blog post to Hashnode" which fits as this is a "***TUI*"** and you can publish posts with this cli!

And there you have this CLI. I'll create a new article that will explain the technical aspects in detail. If I missed any of your *questions* in this article feel free to leave a comment and I'll make sure to answer 'em! ok bye.
