Last active
December 10, 2015 22:38
-
-
Save fumokmm/4503209 to your computer and use it in GitHub Desktop.
JLine minimum sample in Groovy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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