Deeper Look into CLI PROJECT

Munkith Abid
2 min readJan 1, 2022

In this short blog, I’m going to explain how the ruby-docs-cli project works.

This project is my first using the Ruby programming language. It incorporates quite a few Ruby programming and designing concepts, such as DRY, separation of concerns, object relationships, scraping, and many more!. So let’s dive right into it.

The project is mainly built on the https://ruby-doc.org/core-2.7.2/ website, which serves as the endpoint for scraping the data we need. And it also mirrors almost exactly this website in terms of the data structure and navigation as well as the general layout(without the fancy GUI power of course) as we’ll see shortly.

The functionality of the program lays in three major classes and one module, Klass, Mmethod, and CLI, respectively plus one module, namely, scraper module which contains all common features and concerns amongst the previously mentioned classes.

As mentioned earlier that this project was built to reflect the real website that it’s mining its data from, mainly to give the user a sense of familiarity when navigating the CLI similar to clicking various links on the main website. With this in mind, a nested user interface menu system has to be implemented.

The program is extremely simple and basic. It starts with the main menu with only to prompts:

exit; to exit the program.

classes; to list all available classes alphabetically.

Typing classes will also take the user to a submenu implemented by its own loop. This submenu will give the user the following choices

Type in a class name to print the description of that class.

back; to go back to the immediate previous menu

exit; to exit the program.

Assuming the user typed some class name. This will print that class full description and, yet again, take the user to another submenu replacing the options available on that class’s webpage. This time the submenu will provide the following options:

methods; to list all methods of this particular class.

Type in a method name to view its full description.

back; to go back to the immediate previous menu

exit; to exit the program.

At this time if the user decided to continue and type in a certain method name, then as mentioned above, the full description of that method will be printed to the terminal and the same command options menu will be displayed again. No more submenus.

The project also has some extra features, such as suggesting a class or method name if there was a typo and colorizing major keywords and commands.

As previously mentioned, this project is extremely primitive and basic, yet still powerful in its own right. Rooms for improvements are huge, including adding more features, implementation improvement, error handling, refactoring, and many many more.

--

--