Skip to content

Instantly share code, notes, and snippets.

@ksky
Created October 10, 2010 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksky/619117 to your computer and use it in GitHub Desktop.
Save ksky/619117 to your computer and use it in GitHub Desktop.
// 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