Photo by Joshua Fuller on Unsplash

A Field Guide to Building My First CLI Gem

“One step at a time.” This has been my mantra recently as I embarked on my first major project as part of the software engineering program with the Flatiron School. After scouring the internet for resources and how-to guides, it became clear that building command line applications is something of a rite of passage for beginner software engineers. So here we go, this is a brief guide to building a CLI gem that will leave you feeling accomplished and eager to keep building.

  1. Figure out what is meaningful to you — This might seem straightforward, but the task of determining what your program is actually going to do should be something that resonates within you. Are you looking to help others by simplifying a task? Great, go for that. Are you a movie buff eager to know what local theaters are showing? Sounds like a plan. While I was brainstorming ideas, I thought about a lot of different options but ultimately settled on a favorite hobby of mine (*ahem* following the NBA and managing my fantasy basketball team). For me it’s a lot of fun, and ultimately I wanted to build something that would bring me some joy.
  2. Begin with the skeleton files needed to get your CLI app up and running — Ensuring that the basic structure of your program is sturdy is a must. I’m not going to get into too many technical aspects here, but there are of course different ways to go about this (hey there, Google!). At first I had some issues getting everything up and running, like file dependencies. I ended up building the directories and files on my own using this guide and going from there. Even though it took some time to get all of the dependencies set, eventually getting that first “Hello World” to work in the terminal felt like a huge success. Again, one step at a time.
  3. Focus on the most basic functionality of the gem first, then add layers as you go — For me, this was a challenge. I tend to be the kind of person that wants to get from the big idea all the way to the finished product as quickly as possible. There is so much to know and learn in the details, though, so I found that taking things step by step in terms of adding functionality was the way to go. The great thing about this approach is how much you learn along the way. Yes, things are going to be broken, but that’s the fun in programming! How can I solve this problem? What creative solution is going to get me where I need to go? This is where the magic happens. Here are some questions to consider as you are planning: how will a user interact with this app? What is the most useful data for the user to have? Once the user leaves the app, what will they take away from their experience? This isn’t an exhaustive list, but having a solid understanding of these questions will help guide you as you get further into your project.
  4. Make things real — Once the basics are mostly covered (e.g. files are setup properly and working as expected, a simple CLI menu for control flow is in place, classes are beginning to take shape, etc), it is time to make things real. In the world of CLI apps, this is done primarily through the use of actual data obtained through scraping the web. Scraping is all about finding specific bits of information from a website and incorporating it into your application. Think of it like a treasure hunt. The data is out there, it’s just a matter of finding it and being able to reliably obtain it again and again. It takes a lot of patience and practice, but once it works it really allows progress to move along.
  5. Create harmony within your application — Okay, this sounds a little woo-woo, but what I mean is focus on creating classes and objects that play nicely together as you are writing your program. Object Oriented Programming (OOP) is a key concept in software engineering, and building a CLI app shows you just how crucial it is. Fortunately, it is helpful to remember that there are many amazing examples of CLI gems out there to study and learn from. Keep in mind that there’s no need to reinvent the wheel when writing code. Just focus on making something that works well for you and follow the core principles of elegant OOP programming.
  6. Seek advice and help from friends — Once your CLI gem is up and running, it’s an incredible feeling. You feel accomplished (as you should!) and you want to share it with the world. I found it extremely helpful to share my app with friends and family to get real world tests of user experience. If something breaks or doesn’t make sense, the problem (and hopefully solution) will become clear. In addition to that, reaching out to other folks in the Flatiron community has been a huge help as well. The perspective you gain is invaluable as you seek to put the finishing touches on your app.
  7. Stay open to future inspiration and changes as new ideas come up — As I wrap up working on my first CLI gem, I have noticed that I keep finding ways to either add to or adjust my code. I’m pleased with where everything is currently at, but it’s fun to be open to the creative impulses that arise when you’ve been working and spending so much time on a project. There are always going to be improvements that can be made, a more efficient way to solve a particular problem, and many more things that can be learned through these discoveries. This is the beauty of the creative process in action.

There you have it. A few of my humble suggestions for embarking on a journey that is going to have its ups and downs, but at the end of the day is incredibly rewarding…and FUN! Cheers, and happy building.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
DJ Taylor

DJ Taylor

Based in Los Angeles, I’m a full stack developer and recent graduate of the Flatiron School.