Building my first Command Line Interface

Howard Suarez
2 min readDec 14, 2020

For my first project in the Flatiron school I made a command line interface (cli) for ruby. I restarted this project multiple times in many different ways. I tried to make it into a gem at first and it kept breaking and giving me problems especially with the gemspec, so I decided that my mentality would be to just focus on meeting requirements adequately and then going back.

Instead of turning my cli into a gem I simply started by making the repository in github and cloning on to my local environment, I added my directories and files manually and stuck to simply having an executable, an environment and my interface and thats what I worked on. I began with my API code, for this project I used a Superhero API, if you want to use it, it makes you login to facebook to give you a user code. After parsing with JSON I moved on to the file that would hold all of my information (keys,values). Once I finished there I began building my actual CLI, what my user would be interacting with. Something tricky that came up during that phase was I had to use to different kinds of conditionals at two different parts of my code, in the earlier part I used the simple ‘if’ and ‘elsif’ statements and then later on I wanted to make things a little more smooth so I figured out how to integrate a loop into the second level of interaction. I was also able to find some cool designs to spice up the interface look through google. I learned that kind of code art is called ASCII Art and found an informative article on Medium (https://medium.com/@sylwiavargas/adding-pictures-to-your-ruby-cli-4252b89823a)

--

--