Skip to main content

Command Palette

Search for a command to run...

Gopen - A simple CLI to quick-start coding projects

Updated
3 min read
Gopen - A simple CLI to quick-start coding projects
W

My 7-year career journey has taken me from pharmacy to biostatistics and data science, and then to web development. Starting on the front-end side, I built multiple websites, application UIs, and analytics dashboards custom-made for pharmaceutical companies. Now, I'm finding my niche in the back-end side thanks to the elegantly simple Go language, which I used to build Gopen, a CLI that helps me quickly open projects from a terminal, along with some REST APIs and full-stack applications. I love tinkering with software, I write about it in my personal blog, and I'm always looking forward to a new challenge or problem to solve.

The premise of this command-line utility is to save an editor of choice and a list of aliases for your local development projects instead of "polluting" your system-level configs (e.g., .bashrc). Then, Gopen command will cd into that folder and open your editor of choice.

Check the project's GitHub repo for the source code, pre-built binaries, and any relevant documentation. The rest of this article will be more of a blog-like walk-through with my thought process and learnings from the project.

Background

The idea of Gopen started as a potential dogfood solution to the relatively straightforward problem of having to navigate to a project folder and open Neovim every time I open a terminal. I went with the idea that if I had a problem I wanted to solve, it's very likely someone else has the same problem that Gopen would help with. So, I made sure my CLI is usable and well-documented.

It started as a simple command-line tool where you write the appropriate command and supply any necessary arguments in the shell. Then, I upgraded it with an interactive TUI on top, including a search functionality to make it easier to find aliases. This again came from a personal problem that I wanted to solve, and that was that I used Gopen for a long time and added too many aliases for me to remember, which lends itself well to interactive search.

Technologies

The command-line part of Gopen is written entirely in Go and its standard library. Go seems like a great tool for developing command-line utilities like Gopen since it's simple to write, fast to run, and compiles to native OS binaries for anyone to use without the need for the source code and an interpreter.

To add the interactive TUI, I used the popular Go package Bubble Tea. It has a relatively straightforward framework for reactive programming to define the visual components of the UI and the data upon which depends the rendering (and re-rendering) of that UI.

Some small amount of automation was done with a makefile. The file simply contains some commands for formatting, testing, linting, and compiling the three binaries.

GitHub & Collaboration

Because I thought the tool may be interesting for other people to use, I paid as much attention as possible to the GitHub repo. I used the README.md to provide clear documentation on how to install and use Gopen. Pre-compiled binaries (for Linux, Windows, and MacOS) are also available in the releases page for direct download and use.

I shared the repo in Discord servers to ask for feedback, and thankfully, it got picked up by other users and got a few stars. One of them even gave me excellent feedback and then collaborated with me on the project in both issues and pull requests.

Skills

As a portfolio project, Gopen demonstrates these skills with Go:

  • CLI/TUI development
  • Handling command-line arguments
  • File I/O
  • JSON marshaling/unmarshaling
  • Go doc comments on functions and packages
  • Testing with go test
  • Linting with golangci-lint
  • Cross-compiling for multiple operating systems
  • Automation via makefiles

More from this blog

wipdev

38 posts

A Work-in-Progress Developer