DEV Community

Cover image for Adventures of Building a CLI
Patrick-co
Patrick-co

Posted on

Adventures of Building a CLI

Hello again, Coding Community! I'm back to give an update on my coding journey. One month into the Flatiron Software Engineering full-time programing, and let me tell you . . .

IT'S BEEN TERRIFYING AND THRILLING ALL AT ONCE !!!

A dash of anxiety, a pinch of tenaciousness, a handful of Google searches, and a rollercoaster of emotions. Coming from a background of absolute no coding experience until today has certainly proven a unique one. We've gone over and learned, in depth, about Ruby which includes: Arrays, Looping, Iteration, Hashes, Data Structures, Object-Orientation, Class Variables, and Methods. Just to name a few.

With all said and done, each phase in the program finishes off with a project. For phase one, our project to was to construct our very own Command Line Interface (CLI) application from scratch which consumes data from an Application Programming Interface (API). Nothing too fancy, but with enough structure to demonstrate what we have learned so far.
Requirements for our CLI were to the point. Create a CLI which would be user-friendly, and allows for the choice to obtain certain details of selected outside source. A CLI where the data provided must go at least one level deep, prompting a choice for the user to make if said detailed information was wanted.

When starting out with any project, whether it is coding or not, it is always great to start off by mapping your steps of approach. A great thing about code itself, is its fluidity when it comes to writing it. For example, there are multiple approaches that could have been taken to begin this project:

Alt Text

If you draw your attention to the photo above, you can see for my project, I went ahead and manually created my folders, files, and a repo on GitHub. (A lot easier than one might think) Another method of starting this project would be using bundle gem which would create most of the necessary folders and files for you. If you take the second option, just make sure to go through it all to make sure you are only using the ones you need.

A major challenge for me was not the CLI structure itself, but consuming the data from the selected API. There are gems, methods, and shortcuts aplenty when consuming an API, depending on the API and the data source themselves. It is up to you to stay focused and organized when connecting the dots to your final goal. I learned this the hard way from overthinking and falling off the map a bit. From watching one to many videos for aid, and the pages of articles, I threw myself for a loop. Shown below is an snippet of the code I finished off with to complete the task at hand:

Alt Text

From not ever creating such a programming to finally seeing my program run without hiccups, I can honestly say a did shed a tear of enjoyment. My advice to anyone out there who is embarking on the challenge of making their own CLI, I say, "remember to double-check all your spelling for typos". Also not to be afraid to ask for help, no matter how small or "easy" the question may be.

β€œIt always seems impossible until it is done.”
– Nelson Mandela

Top comments (0)