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:
https://github.com/eliangcs/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:
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.
No one cares..