So, you’ve made it to the 3rd and final week of Mod 1 at Flatiron School (and you still have no idea how you endured that first code challenge). You know what that means? PROJECT WEEK!!! 🎉🎊
You finally get to develop something of your own and watch it come to life. After days of drilling into your memory how to distinguish between class and instance methods (“.” means it’s a class method and “#” means it’s an instance method, in case you still didn’t know, you should probably go back to the Animal Zoo lab), it’s time to invoke the powers of your right brain and tap into that creative side of yours. The most exciting part of the Mod 1 project is getting to utilize **drumroll** (no, the answer is not Active Records, but that’s cool too) TTY-PROMPT!
TTY-prompt is an amazing Ruby gem for your command line project. It grants you the ability to transform a terminal’s mundane interface into an aesthetically pleasing and interactive one.
A popular and common use of TTY-prompt is to create select/multi-select option questions with a menu like this:
However, there are more TTY capabilities to explore! TTY has a number of other useful gems that can help decorate your command line. You can also add colors to your text, have different fonts, and incorporate simple animations!
This website provides you with all the available TTY gems.
All you need to do is 1) go to your Gemfile 2) add the gems you want 3) run bundle install.
Pro-tip: If you’ve already run bundle install before adding these gems, delete the Gemfile.lock file first. Then, add the gems and run bundle install.
The TTY gems I used for my Mod 1 project are pastel, tty-color, tty-font, tty-progressbar, and tty-spinner.
Both pastel and tty-color gems change the colors of your text. To implement pastel, type the following:
To have your text color change when a specific choice is selected, you can use tty-color. Add this method at the top of your file and choose the color you want your “active color” to be.
To have your titles and app names appear more prominent, you can use tty-font. Though I have to admit, there are not many options as to what fonts you can choose from, but they will still make your command line look a bit more lively. Type this:
Another pro-tip: You can combine pastel and tty-font methods by saying:
My favorite TTY gems are tty-progressbar and tty-spinner because they allow you to display cute little animations to the command line. Yes, I know, loading progress bars and spinners are not necessarily fascinating or entertaining as far as “animations” go, but it’s better than nothing. Don’t you know that it’s the little things in life that can bring us joy?
I used the progress bar and spinner to illustrate whenever the application was “processing” a request made by the user. To implement the spinner, type this:
You can also add a message alongside the spinner and select a format of your liking. Here is a link that shows the different images your spinner can appear as.
You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
Last but not least, the good ol’ classic progress bar. To display a progress bar in your command line, type this:
Similar to the spinner, you can also add a message alongside with the bar and choose from various formats to depict the progress.
Now, off you go on your CRUD adventure! You are now readily equipped to makeover and design your command line to your heart’s content!