tags:

views:

114

answers:

3

If I want to have a prompt on the terminal with a default value already typed in, what library should I use?

Ruby's standard Readline.readline() lets me set the history but not fill in a default value (as far as I can tell, at least)

Something like:

code:

input = Readline.readline_with_default('>', 'default_text')

console:

> default_text|
+2  A: 

Sounds like a job for ncurses. Seems like rbcurse (http://rbcurse.rubyforge.org/) is the best maintained API at the moment.

Farrel
A: 

Highline doesn't do exactly what you describe, but maybe it's close enough.

Ken Liu