Project CLI

Wesley Spencer
4 min readDec 6, 2020

--

CLI stands for Command Line Input. A CLI program accepts text input to execute operating system functions. This was once the only way to communicate with a computer, through its terminal, back in the 1960s.

I am currently in Flatiron Bootcamp to become a software engineer. The CLI project was the first project of my Phase 1 of being in Flatiron. This project presented many challenges, but this project also helped me understand the importance behind the Ruby language. This was my journey through my CLI project.

Step 1: bundle gem “{name of project}”

First I made a file and repository for my new gem. I made a new directory where I will store my new gem. After making my directory, I inputted into my terminal “bundle gem {name of project}”. This will create all the folders I will need for my CLI project. In the photo I presented, you will see that my directory is lacking some folders and files. The folders and files I deleted were pertaining to publishing my gem; this was unnecessary, as I probably wouldn’t be making a master piece my first time around.

After requiring all my folders, I can set up my environment for my CLI project; such as requiring my gems. Gems are an important part to any ruby program, they are other programs that help make your life just a little bit easier. After setting up your environment, it is time to move on to the next step.

Step 2:Send a get request

This was one of my harder challenges. I had to find an API to call on in my program. I decided to go with an API I found for a game I really like called League of Legends. The requirement that was set for this project was to create an object and call on it to present some info or statistics. I had to “bundle install” the gems I required in my gemfile. After the installation of gems, I made my API folder, class and instance method. I would need to use the Rest Client Gem to get the API presented in the URL. After I used the JSON Gem to parse all the data that I wanted. I then created another file called champions where I would be making the objects for my project.

After initializing all the attributes I am now able to go back to my API and make new objects and pass them into my class variable “@@all”. Once doing this I was ready to create your CLI file!

Step 3: Making my CLI

I created a CLI class, then added my Start method which would greet the user and I would also call my API class and instance method to load all the data into my CLI file. Next, I would work on the flow of the file. Create methods that would ask for user input, accept user input, print list of champions, select champions, etc. You can see all the methods in the pictures below.

Each and every one of these methods takes the users input, accepts it, and returns the values of said champion. The list_champions method I ended up getting help from a buddy in my cohort to print the champions out into columns. This was not a requirement in the project, but I did want to make is esthetically pleasing, and let me tell you how esthetically pleasing I my made my CLI program. In fact I made it look so good my class mates had to write memes about me!

In conclusion, I had a lot of fun making this CLI program. It has helped solidify my confidence in ruby and I am excited to move on to Phase 2!

You didn’t think I would leave you hanging did you?https://www.youtube.com/watch?v=9YmtbInFQpQ&feature=youtu.be

--

--