Skip to content

Instantly share code, notes, and snippets.

@namnv609
Created October 24, 2025 09:16
Show Gist options
  • Select an option

  • Save namnv609/fe69467b7b00aee16b279842dc822653 to your computer and use it in GitHub Desktop.

Select an option

Save namnv609/fe69467b7b00aee16b279842dc822653 to your computer and use it in GitHub Desktop.
Simple Groovy Pry
/**
* Mini pry / interactive shell cho Groovy CLI
* @param bindingMap: map các biến bạn muốn expose trong shell
*/
def pry(Map bindingMap = [:]) {
def binding = new Binding(bindingMap)
def shell = new GroovyShell(binding)
println "=== Entering mini Groovy pry ==="
println "Gõ 'exit' để thoát và script tiếp tục"
while(true) {
def line = System.console().readLine("groovy-pry> ")
if (line == null || line.trim() == 'exit') break
try {
def result = shell.evaluate(line)
println result
} catch(Exception e) {
println "Error: $e"
}
}
println "=== Exiting mini Groovy pry ==="
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment