Created
November 26, 2022 18:36
-
-
Save comdotlinux/c8c37df48f1bb30fbb9b3e85b785dd18 to your computer and use it in GitHub Desktop.
A confirmation Dialog From WIthin Gradle.
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
import javax.swing.JOptionPane | |
tasks.register("askConfirmation") { | |
doLast { | |
if (confirmation("Do you want to answer me?")) { | |
logger.lifecycle("😃 You Answered Yes!!!!") | |
} else { | |
logger.lifecycle("😒 You Answered No 🤷") | |
} | |
} | |
} | |
fun confirmation(msg: String = "Continue?"): Boolean { | |
return if (System.console() != null) { | |
"y".equals(System.console().readLine("$msg [y/n] : "), ignoreCase = true) | |
} else { | |
JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Confirm operation", JOptionPane.YES_NO_OPTION) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment