Phase 1 Project- CLI

This is the first project creating a command-line interface(CLI) with an application programming interface(API).

Before we begin, let's define what is a CLI and API. A CLI is a process command to a computer program in the form of lines of text. An API is an interface that defines the interaction between multiple software applications or mixed hardware-software intermediaries.

So first off, you can choose which API from github.com/public-apis/public-apis. It gives a variety of things to choose from like Breaking Bad, which is the one I chose.

In my CLI and API class, I was having some difficultly connecting the two classes. Well some help pointing me in the right direction, the problem wasn't in the API class. It was actually in the CLI class in one of the methods, which was list_characters. (see next photo.)

In the self.get_data, the Character.new(character) I had something that kept getting an error. Which was getting an error when I ran ruby bin/run.

Ruby bin/run runs the application in the terminal. Connecting the CLI, API, and whatever name you choose, in this case, its character.

Anyways, I had Character.new(characters) not (character). Which kept going on for a while before I realized I added an “s” to character. After correction, I finally asked for some help to point me in the right way.

So in the second photo, before puts, I had “#{index}. #{character}”. With some help pointing in the right direction. I forgot to add .name after character. So that looks like puts “#{index}. #{character.name}”. (see second photo above)

After these corrections, everything started to run smoothly.

This project was interesting and fun to make. It gave me an insight into CLI and APIs. I'm looking forward to the next phase and phase project 2.

Sources:

https://en.wikipedia.org/wiki/Command-line_interface

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store