Created
October 24, 2025 09:16
-
-
Save namnv609/fe69467b7b00aee16b279842dc822653 to your computer and use it in GitHub Desktop.
Simple Groovy Pry
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
| /** | |
| * 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