My First Multi-Select TTY::Prompt

Radiyah Sabur
3 min readMar 31, 2021

A Beginners Guide to Using Multi-Select TTY::Prompt in a Ruby Command Line Interface App

So get this, I’m 2 weeks into Flatiron School’s Immersive Software Engineering bootcamp when my cohort and I are tasked with pair programming our very own Ruby CLI app. As a beginner in everything code related, my first instinct was to panic!

Me Panicking! 😬

After I got that out of my system and actually started to code, I realized that, from what I learned in those two weeks, I was well equipped with the knowledge needed to actually create this app. I also knew that whatever my partner and I didn’t know, my instructors and Google would had our backs!

Building this app was a lot of fun, but one thing that I found quite interesting was the ability to use a prompt that would select multiple things all at the same time! So, without further adieu, this is a step-by-step guide on how to implement a Multi-Select Prompt using TTY Prompts.

STEP 1: Install That Gem

The first thing you’ll need to do is add the TTY::Prompt gem in your app’s Gemfile, like so:

gem ‘tty-prompt’
Add this line into your Gemfile

This will allow you to access all types of prompts within you app. After you’ve added the gem, you can go ahead and execute a bundle install in your terminal.

STEP 2: Using The Gem

Once your install is complete, the next thing you’ll want to do is create a class variable of prompt and a new instance of the TTY::Prompt class within your app. In order to have our app start of with the ability to use TTY::Prompts, we added it to our initialize method, like so:

This way, instead of having to type out the full method, you can just call on prompt.multi_select(‘Your Question Here’) in a method. Here is an example of what your multi-select function should look like and output:

Example from TTY::Prompt Doc

STEP 3: Take It For A Test Drive

Next thing you want to do it test it out. Check out this short demo on the Multi-Select functionality that I recorded from my CLI app.

I don’t know about you, but I found this to be super useful. Imagine having to select one movie at a time to add to a list! Eh, that’s not for me. #MultiSelect4Life

STEP 4: Celebrate 🎉

Congratulations! You’ve just implemented your very own Multi-Select TTY Prompt and well on your way to creating a dope CLI app.

Confetti-fy Yo Self! 🎉

Hope you found the Multi-Select functionality as interesting as I did. While this isn’t the only TTY::Prompt we used in our app, this is the one I got really geeked about. There are a bunch of other features that TTY::Prompts have to offer and you can explore them here. I also found here to be quite insightful.

Happy coding!



Radiyah Sabur

Software Engineering Student at Flatiron School. I love Fashion, Film and all things sparkly.