Skip to content

Instantly share code, notes, and snippets.

Last active June 3, 2020 06:49
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliangcs/464a05ab75ac2a44d2e3dc0ac141cbc6 to your computer and use it in GitHub Desktop.
Save eliangcs/464a05ab75ac2a44d2e3dc0ac141cbc6 to your computer and use it in GitHub Desktop.
How I created HTTP Prompt and got 5000+ stars on GitHub

How I Created HTTP Prompt and Got 5000+ Stars on GitHub

Two months ago, I published an open source project, which went viral by gaining 1200+ stars in the first 24 hours. As of this writing, it has attracted 5000+ stars. The project is called HTTP Prompt:

Here I want to share its development story.

It all began with Vertica. Not long ago, I used Vertica every day for my work. Vertica is a powerful database, but the official client (vsql) is not powerful at all. The GUI alternative, DbVisualizer, is bad as well.

I recalled there is a good PostgreSQL client called pgcli, which made me think, it probably won't take me too much effort to fork and retarget it to a Vertica client. Just as what I expected, it only took several days for me to write vcli.

I emailed pgcli's author, Amjith Ramanujam, telling him "I took your project and made it something else." He was kind enough to write me a promotional post on his pgcli website. But Vertica itself doesn't have many users in the first place, so vcli didn't get much attention. But at least with vcli, I could finally use Vertica happily ever after.

In fact, vcli, pgcli, and mycli (for MySQL) are all based on a Python package named prompt-toolkit. With the enhancement of prompt-toolkit, command-line applications become a lot cooler because of autocomplete and syntax highlighting. Check out how many projects are based on prompt-toolkit and you'll know what I'm saying.

Back then I often needed to test and debug HTTP/REST APIs, which should be a part of many people's daily work, too. I believe most people would use a GUI tool like Postman to do the job. However, using a GUI app is not so handy for a guy who develops in a command-line interface environment. That's why I chose HTTPie, a curl-like tool. But one thing to complain about HTTPie is you have to type a lot. Unlike how Postman automatically remembers your previous state, HTTPie is stateless. Then I had this idea, it would be awesome if HTTPie offered an "interactive mode". I did a little survey and found out the same idea had been there over a year ago.

Even five years ago, someone already wrote a tool called HttpShell similar to what I was imagining. But I didn't want to quit the perfectly-designed HTTPie, and HttpShell seemed unmaintained, so I didn't pay too much attention to HttpShell.

"With the enhancement of prompt-toolkit, command-line applications become a lot cooler." Then why don't I just stand on the shoulders of giants, combining HTTPie and prompt-toolkit to create an HTTP client with autocomplete and syntax highlighting? It must be a huge selling point by not asking users to abandon the wonderful HTTPie.

Then I started to work on HTTP Prompt. I told my wife, I could get at least 1000 stars on GitHub. I was not guessing wildly. pgcli has 4000+ stars and HTTP must have much more users than PostgreSQL, so if I execute this right, attracting 1000 stars is not a problem.

In the beginning, I spent most of the time finding a perfect solution so that the three main modules: autocomplete, syntax highlighting, and command parsing, could be done with a universal context-free grammar (CFG). But the author of prompt-toolkit, Jonathan Slenders, told me the idea isn't practical.

So in the end, only command parsing was implemented with a CFG. The other two components were handcrafted. The other tough question is parsing a CFG. Luckily, I found an existing package called Parsimonious that does exactly it. (Technically, Parsimonious is a PEG parser. See how it differs from CFG here.)

You can see from his code, the author of Parsimonious, Erik Rose, must have a solid understanding of compilers or formal languages. One does not simply write something like that without that knowledge.

prompt-toolkit solves most of the hassle problems, so the whole development was smooth except for the CFG mentioned above. After finishing the basic functionalities in about three weeks, I published the project link to Reddit/programming. The post didn't take long before it went to the top 1 on the front page.

Reddit was really effective. Most of the traffic of HTTP Prompt came from Reddit. The stars were increasing almost by the speed of one star per minute, which eventually made it climb to the top 1 on GitHub Trending. My wife took a photo for me as a memento:

Top 1 on GitHub Trending

Issues and pull requests came with the stars. Many of them were actually valuable suggestions, which I accepted and released in the later versions.

Doing open source projects is fun. When you realize there are many people using your software and giving you feedbacks, you know you're doing something meaningful. I hope this article could encourage more people to use HTTP Prompt and help people who want to participate in open source projects, especially for those who want to contribute to HTTP Prompt :P.

Copy link

ghost commented Jul 11, 2016

No one cares..

Copy link

ghost commented Jul 11, 2016

No one cares..

Speak for yourself Dillybob92.

I for one found the explanation useful and I am sure others will find it useful as well to some extent.

Copy link

duckie commented Jul 11, 2016

That's cool but the beginning is the easiest. Will you maintain over time ? Do you want to ? You make it sounds like you were after the stars before anything else

Copy link

eliangcs commented Jul 11, 2016

@duckie yes, I will and want to maintain it over time. The stars are a part of the motivation, but the biggest motivation is to build something I want to use for myself.

Copy link

@eliangcs good luck. Hoping to see it cross 10K stars soon :-)

Copy link

Very helpful read. Thanks for sharing!

Copy link

panzerdp commented Dec 9, 2016

Very interesting. Thanks for writing the story and success with your project!

Copy link

Interesting, thanks for sharing and well done!

Copy link

quite interesting.. thanks

Copy link

amjith commented Jul 25, 2017

That's an awesome story man. I'm flattered that you credited pgcli for your inspiration.

You've created something that a lot of people use and love. Well done!

Copy link

@amjith pgcli is awesome. It is still one of my most frequently used tools, possibly more frequent than http-prompt!

Copy link

Cool story!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment