I have a very simple groovy script that reads a username and password from the console. If I run the script from the command line it works perfectly. However, if I try to run it from within Intellij, the console is null.
How can I read console input while debugging my script?
String username
String password
def console = System.console()if (console) { username = console.readLine('> Please enter your username: ') password = new String(console.readPassword('> Please enter your password: ')) println "username: ${username} password: ${password}"}else{ println "Cannot get console, exiting..." System.exit(1)}