Skip to content

Instantly share code, notes, and snippets.

@fumokmm
Last active December 10, 2015 22:38
Show Gist options
  • Save fumokmm/4503209 to your computer and use it in GitHub Desktop.
Save fumokmm/4503209 to your computer and use it in GitHub Desktop.
JLine minimum sample in Groovy.
@GrabResolver(name='jline', root='http://jline.sourceforge.net/m2repo')
@Grab(group='jline', module='jline', version='0.9.9')
import jline.*
def prompt(ConsoleReader reader, String msg, Closure clos) {
while (true) {
def line = reader.readLine(msg)
if (line in [null, 'exit']) break
clos(line)
}
}
def reader = new ConsoleReader()
reader.bellEnabled = false
prompt(reader, '> ') { line ->
println "--> [${line}]"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment