# Menu-driven Console Application in Ruby

**URL:** <https://rubytalk.org/t/menu-driven-console-application-in-ruby/57504>\
**Category:** ruby-talk\
**Created:** [22 February 2010 15:38 UTC](https://rubytalk.org/t/menu-driven-console-application-in-ruby/57504 "2010-02-22T15:38:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@Joe\_Martin1](https://rubytalk.org/u/Joe_Martin1)\
**Post date:** [22 February 2010 15:38 UTC](https://rubytalk.org/t/menu-driven-console-application-in-ruby/57504/1 "2010-02-22T15:38:28Z")

</div>

Hello  
I'm trying to create a console application with ruby on Windows. I wish  
to have it menu driven, so each screen the user sees is essentially a  
menu, where the user can enter a number (representing their menu  
choice), such as:

> **···**
>
> -----------------------------  
> Welcome to my application!
> 
> Menu  
> 1. Perform some action  
> 2. View option list  
> 3. Exit application
> 
> Enter selection\> \_  
> -----------------------------
> 
> Really I'm looking for skeleton or sample code for a console  
> application. A few google searches did return skeleton code for a  
> command-line and console applications, but everything I found was more  
> geared towards command line applications (that is, skeleton code for  
> parsing out parameters, proper help syntax, etc), and not creating a  
> menu-driven environment.
> 
> I already have the program basically written out and working, but it's  
> very hacky with many if-else and when-case checks, so I'm hoping that it  
> could be structured and written out in a cleaner fashion--just not quite  
> sure where to start, and I'm out of ideas on what other ways (or other  
> libraries) are viable options for me. The menus of this application wil  
> be multiple levels deep, so that needs to be kept in mind as well.
> 
> Any ideas on where to start? I'm willing to start the application from  
> scratch if the end result is cleaner, more standard code.  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Richard\_Conroy1](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@Richard\_Conroy1](https://rubytalk.org/u/Richard_Conroy1)\
**Post date:** [22 February 2010 16:59 UTC](https://rubytalk.org/t/menu-driven-console-application-in-ruby/57504/2 "2010-02-22T16:59:34Z")

</div>

You should look at the ncurses gem/project.  
[http://rbcurse.rubyforge.org/](http://rbcurse.rubyforge.org/)

\<[http://rbcurse.rubyforge.org/&gt;You](http://rbcurse.rubyforge.org/&gt;You) will probably need to do a bit of  
googling for tutorials and such

> **···**
>
> On Mon, Feb 22, 2010 at 3:38 PM, Joe Martin \<joseph.w.martin.ctr@navy.mil\>wrote:
> 
> > Hello  
> > I'm trying to create a console application with ruby on Windows. I wish  
> > to have it menu driven, so each screen the user sees is essentially a  
> > menu, where the user can enter a number (representing their menu  
> > choice), such as:
> 
> --
> 
> > **[Richard Conroy's Personal Blog](http://richardconroy.blogspot.com)**
> >
> > Random thoughts on Life, Pictures, Sailing, Software Development, Games, Skiing and random things from the internet. May contain Rants.

---

<div class="post-metadata">

**Author:** ![Gabriel\_Horner1](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@Gabriel\_Horner1](https://rubytalk.org/u/Gabriel_Horner1)\
**Post date:** [22 February 2010 20:00 UTC](https://rubytalk.org/t/menu-driven-console-application-in-ruby/57504/3 "2010-02-22T20:00:08Z")

</div>

Highline, [http://highline.rubyforge.org/](http://highline.rubyforge.org/), has a pretty good menu  
widget: [http://highline.rubyforge.org/doc/classes/HighLine/Menu.html](http://highline.rubyforge.org/doc/classes/HighLine/Menu.html)  
Hirb , [GitHub - cldwalker/hirb: A mini view framework for console/irb that's easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu.](http://github.com/cldwalker/hirb), also has a decent one:  
[Tagaholic - Two Dimensional Console Menus with Hirb](http://tagaholic.me/2010/02/16/two-dimensional-console-menus-with-hirb.html)

Neither one of these requires using curses which may be a good thing  
being in windows.  
I don't think either one of these supports multiple levels.

> **···**
>
> On Feb 22, 10:38 am, Joe Martin \<joseph.w.martin....@navy.mil\> wrote:
> 
> > Hello  
> > I'm trying to create a console application with ruby on Windows. I wish  
> > to have it menu driven, so each screen the user sees is essentially a  
> > menu, where the user can enter a number (representing their menu  
> > choice), such as:
> > 
> > -----------------------------  
> > Welcome to my application!
> > 
> > Menu  
> > 1. Perform some action  
> > 2. View option list  
> > 3. Exit application
> > 
> > Enter selection\> \_  
> > -----------------------------
> > 
> > Really I'm looking for skeleton or sample code for a console  
> > application. A few google searches did return skeleton code for a  
> > command-line and console applications, but everything I found was more  
> > geared towards command line applications (that is, skeleton code for  
> > parsing out parameters, proper help syntax, etc), and not creating a  
> > menu-driven environment.
> > 
> > I already have the program basically written out and working, but it's  
> > very hacky with many if-else and when-case checks, so I'm hoping that it  
> > could be structured and written out in a cleaner fashion--just not quite  
> > sure where to start, and I'm out of ideas on what other ways (or other  
> > libraries) are viable options for me. The menus of this application wil  
> > be multiple levels deep, so that needs to be kept in mind as well.
> > 
> > Any ideas on where to start? I'm willing to start the application from  
> > scratch if the end result is cleaner, more standard code.
