GitHub's Go-powered CLI
In this episode we discuss Mislavās experience building not one, but two Github CLIs - hub and gh. We dive into questions like, āWhat lead to the decision to completely rewrite the CLI in Go?ā, āHow were you testing the CLI, especially during the transition?ā, and āWhat Go libraries are you using to build your CLI?ā
Matched from the episode's transcript š
Mislav MarohniÄ: Well, when it came from learning what really worked with the hub tool, and then choosing how much of that we wanna promote of that spirit, to eventually being GitHub CLI as an official tool, we mostly went over its feature set and decided that its fundamental design paradigm was not something that we wanted to port over. And then after that, considering inputting any of its code, itās actually really already ā it doesnāt align with that first and foremost decision, which we eventually were pretty secure in⦠Because if you donāt wanna preserve the spirit, a design of how a tool works, then itās just really hard to get anything from it, especially due to the fact that being my first Go project, I let the Go packages become basically huge, to the extent where ā I think there were largely just two Go packages where most of the hub implementation lied⦠So to cherry-pick the good parts out of that and leave out the bad parts would have been something thatās not really feasible technically, and I think itās very bug-prone.
[35:48] Another thing is that we didnāt wanna go with the same testing approach, so now weāre copying over parts of the implementation, but weāre actually not gonna port over to Ruby Test because we wanna commit to the Go stack and the default Go tooling to make the project more approachable. With that line of thinking, it was a little bit obvious that starting from scratch would the be right decision.
I appreciate that you brought it up - itās not an easy decision. It should never be made lightly. And I think rewrites should never be made lightly as well, because these are technologically really risky endeavors. But what made it a little bit less risky in our sense is that we were promoting kind of like a semi-official tool to another one. And even if we broke a lot of things, or didnāt port a lot of functionality over - well, we didnāt actually erode trust, because we were launching this new tool, which starts over from version 0.0.1, and who wants to follow us on our journey can, and who wants to stay safely embedded with the tool that already works for them also can.
And I felt that we couldnāt have kept the trust if we tried to make radical changes, and then mostly just disappoint people (I would say) that used hub to do a lot of automation; I also personally loved doing that. They would be the ones who were most affected then, trying to upgrade to a newer version and finding out that their scripts are broken, and that that tool that theyāve used as a reliable Swiss Army knife is not as reliable. That would be my nightmare scenario personally, and we avoided it.