DEV Community

Cover image for The Making of a CLI Project
CraigSmith789
CraigSmith789

Posted on

The Making of a CLI Project

I recently completed a Bootcamp assignment to create a CLI (Command Line Interface) application. The application should allow a user to request data from a web server. The user should also have the option of drilling down for additional information on a specific item. I had the option of choosing between scraping the data or using an API (Application Programming Interface). The API route seemed more stable to me since I would not have to worry about a website being changed and causing my scraper to no longer work.

I searched for an API and discovered one that delivered information on vehicle diagnostic codes or OBD-II PIDs(On-board Diagnostics Parameter IDs). While perhaps not the most exciting topic, it does a great job of meeting the project requirements. The data provided is Code Number, Description, and Possible Causes. This allows a user to see the code along with a description and then decide if they want to see the possible causes.

The application has three classes. The CLI class manages any interactions with the user. The API class is responsible for retrieving the requested data from the remote server. And lastly, the OBDCode class has the duty of storing and iterating through the vehicle code data.

This was my first ever CLI project and I have to admit to being somewhat intimidated (ok, panicked) at first. I found that if I just walked through the process and focused on getting one method working at a time, it started to feel manageable. When I finally managed to have each Class doing their assigned responsibilities correctly, it was just a matter of putting the interaction between the classes in the proper and logical order.

One thing that really surprised me was the flexibility that CLI allowed. My CLI experience up to this point had been entering data at a prompt and seeing a return prompt. I soon learned that the capabilities went beyond just providing a series of please enter 1, 2, or 3 prompts. I could actually give users a menu to select from. This not only looked great, but it also eliminated input validation.

Alt Text

In the end, panic eventually turned to excitement as each corrected error message added additional functionality to the application. I certainly learned a lot from this experience. It was my first CLI application, my first time working with APIs, and I also learned that a P-0300 diagnostic code is Random / Multiple Cylinder Misfire Detected.

Top comments (0)