My first CLI Project at Flatiron School
By: Orkun Sağlam
Tags: First Project, Rubygems, Flatiron School

It was really challenging for me to come up with a CLI project at the beginning. I wanted to build a CLI Gem that lists all the football clubs across the world and provides roster information for each team based on user selection. And guess what? That didn’t happen due to lack of free API sources. All the API sources that I had found for my idea were asking API key-based authentication and I had no idea how to do that at that time. I kind of got scared and decided to go with something else. (I eventually figured that out but, then it was too late for me to start over.)

Then, I started to search for a free API that doesn’t require any key. I also wanted it to be a subject I was interested in. Finally, I was able to find that on Github. The Breaking Bad Api.

I was a huge fan of that TV series and I really loved all the characters in that show. So, I decided to build a CLI that lists all the characters and some famous quotes from the show. Also as a project requirement, I had to go one level deep in my CLI so I decided to give more detail about characters based on user selection.

The plan was made and now I had to put that plan into codes. First, I took my cohort’s leader advice and started off with API class. I, also, wanted to see the data I am pulling from API source first. I did write my code in my Api class but, eventually, I realized that I had written lots of unnecessary codes in my API class at the beginning for no reason. I was trying to pull the character details through a second API request which was not needed. Later, I realized that I could instantiate all the attributes I want upon initialization and iterate over my class variable when I need to use them in my CLI class. So, I had to refactor my API class all over again.

Then, I jumped to creating my Character class. That part was easy honestly. I set the attributes for only “name”, “birthday”, “portrayed”, “occupation” and “character id”. Although,“ character id ” was a key attribute for me. Later on, I would be using that in a method called “find_by_id” in order to call a specific character with its details in my CLI class. That would be the same for Quote class. It was easy to manage. I just wanted to instantiate the quote and its author. I wanted to display them as below.

My hardest struggle, CLI.RB

I think that’s where you make a difference because creating a CLI class defines your interaction with the user. There’s no doubt that you should be creating something that doesn’t break easily but, also, the appearance of your program matters too. After I wrote my methods for the menu, it took forever, by the way, I decided to focus on the appearance of my CLI. After a little research, I was able to find something called ASCII ART

Basically, it converts the text you type to an image that you can use as an artwork in your CLI gem, like an album cover. It works perfectly if you use it with colorize gem in your CLI gem. I also, put a lot of sleep methods in order to give a natural feeling to users.

I got everything together finally; I was able to create my first CLI project. I learned a lot from it. No kidding. If you are about to start a project like mine, please keep the following things in mind.

Do not overthink. simplify !!!

If you hit a wall in your project, just stop whatever you are doing, you won’t be able to fix it right away anyways. I guarantee you. You need to just take a break and relax.

First focus on only the importance of MVP, you can always add more features to your product later.

OH, and always listen to your wife. She knows what’s best for you :)

GEMS I USED

RestClient in order to send a request to API source.

in order to send a request to API source. Colorize for the appearance of my gem.

for the appearance of my gem. JSON to display the data I pulled from my API source in JSON format.

to display the data I pulled from my API source in JSON format. PRY to debug and modify my code.

Feel free to check out my repo here.

Thanks for your time.