Created
October 10, 2010 09:59
-
-
Save ksky/619117 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// g100pon #96 jlineで行編集/補完/ヒストリ付きコマンドライン | |
import jline.* | |
reader = new ConsoleReader() | |
user = reader.readLine('User Name: ').trim() | |
passwd = reader.readLine('Password: ', '*' as char) | |
println "User $user logged in." | |
reader.history.clear() | |
commands = ['bye', 'test', 'debug', 'verbose', 'help'] | |
reader.addCompletor(new SimpleCompletor (commands as String[])) | |
cmd = '' | |
while (cmd != null && cmd != 'bye') { | |
cmd = reader.readLine('Command> ')?.trim() | |
// do something with cmd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment