My First Flatiron Project, CLI

Jason Macklin
3 min readApr 16, 2021
attr_accessor :CLI?, :The Project, :Coding My Project, :Finished?

What is CLI?

CLI stands for Command Line Interface! Sums everything upright? A Command-line interface is a tool used to interact directly with computers since 1960. With the introduction of the interface of Graphic User Interface (GUI), most users never have to work with CLI, yet it is still used by system administrators and software developers.

The Project

The challenge for the CLI project is to use the knowledge we have learned thus far in the curriculum to grab and extract data from an API ( Application Program Interface) and using that data to create an interface for a user to navigate through.

For my project, I chose a topic that I myself was curious about and interested in learning more on the topic, CryptoCurrency. My project allows a user to find the current rate of a crypto coin (in this example BitCoin) for a selected currency. This sounds really great in my head, but I needed to plan out how my user will interact with my CLI and get the correct information. So I made a few notes on what I wanted the user's experience to be like.

  1. User should be able to select from a list of currencies
  2. User should be able to see the current price of bitcoin for the selected currency
  3. If a user chooses an unknown selection, the user should be prompted to the main menu
  4. The user should be able to exit the CLI

Coding Out My Project

def greet(reader)puts "Greetings #{reader}, Thanks for visiting this blog!"#binding.prymenuend

When coding out this project, I needed to map out the CLI relationship to the user, what is the CLI expecting the user to do or want. If the CLI is heavily dependant upon the user's interaction, then let's map that out first. This step reminds me of an RPG walkthrough because it requires a user's response before prompting the next step. I had to develop methods for the following.

  1. Welcoming the user
  2. Greeting the user by name (with interpolation) and inviting them to explore the CLI
  3. A way for the CLI to read the users response and react accordingly
  4. I need to be able to indicate that the user is leaving the CLI
  5. I need to be able to indicate that the user has entered an invalid entry
  6. Show the user Currency options
  7. Show the user corresponding bitcoin information for the chosen currency
  8. Allow the user to stay within the CLI and reselect options.

Once these methods were built out and tested, it's time to actually input the data from the API. Here it's important to understand what data you actually need and how to grab it. I wanted to show the user the currency name, the rate of bitcoin against that currency, and a description of that currency. Using iteration, I was able to extract the data properly; however, this took some time for me as there are specific levels in this hash that I wanted to access.

Hash — “A Hash maps each of its unique keys to a specific value.” — https://ruby-doc.org/

Iterator — “The iterator is an object (sometimes we say method) allowing to iterate over the data set. So, we can go in loop over each object in the collection and do some repeatable work.” — https://womanonrails.com/ruby-iterators

Finished But Not Complete

I have the data, and I have the command instructions that I tested before that works, I'm in a good place to put this sandwich together. I've found that asking questions and making time for 1–1 appointments have been the biggest help. If I had to give my previous self a bit of advice, it would be to “ make big plans but pay attention to the minor details and always require pry.” The times I've found myself stuck was always over one-line/ word of code, which can be and has been frustrating, but I'm happy I completed this project.

If you would like to view my demo, please see the link below, and thank you for visiting.

def goodbyeputs "Thanks for stopping in, have a great day"end

--

--