Phase 1 CLI Project

Mcrea
4 min readDec 2, 2020

--

I start by starring at my first blank canvas. My initial thought process going into the very first project for my coding camp was to use something I was familiar with; cats.

The project requirements was to build a Ruby Gem that provides a Command Line Interface (CLI) to an external data source.

As shown above, I used an API to access remote data, then parsed that information using JSON in order to comfortably use all the information listed in my code.

I chose to make a program that lists all the different cat breeds, and then allowing the user to choose a specific breed with some facts.

In order to do this, I took some of the information retrieved and created a “Breed” class. The purpose of the Breed class is to store a list of all the breeds and their attributes, which you can see below.

My biggest challenge was to get the API to work correctly, thankfully some of my peers were willing to help out and my issues were solved. Team work is definitely important, not only in the learning processes but also in a job setting. One of my silliest mistake.. spelling, a second pair of eyes caught this error below.

At this point my API was working and my project started to come together.

Time to create a Cli class and start coding in some methods!

I started off by creating a start method, which greets the user while it loads the data from behind the scenes to prompt a main_menu_options method. Here the user will be given the option to list all the breeds of cats or to exit the program. The user then inputs their choice in the main_menu to return a method based on the result. For example, if they enter “1” to list the different breeds of cats, the program will return list_breeds method. If user inputs “exit” they will end the program.

After the user gets a list of all the breeds of cats, the program kicks over to the breed_details_menu_options method. This prompts the user to pick a breed of cat they wish to know more about and once they input their option, then sends the program to the next method of breed_details_menu.

The breed_details_menu method is responsible for getting the user input and sending the program to the next method, print_breed_details(breed). This lists facts about the breed of cat the user had selected. The user has the option to list the cat breeds again, or to end the program. There is also functionality that disallows any invalid input and redirects the user back to the menu without causing errors or exiting the program abruptly.

This project was challenging but at the end I was satisfied with what I had accomplished. This was the first time I felt as though I could actually call myself a “coder”.

--

--