This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_5_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit cc5845718cbd4e80bbb95dc68143683b4b7af706
Author: Paul King <[email protected]>
AuthorDate: Thu Jan 15 16:12:38 2026 +1000

    GROOVY-11839: minor refactor
---
 .../src/main/groovy/org/apache/groovy/groovysh/Main.groovy   | 12 +++++++++++-
 .../org/apache/groovy/groovysh/ProgrammaticStartTest.groovy  |  4 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
index 0ef1b23eed..35d2bd6422 100644
--- 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
+++ 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
@@ -297,7 +297,7 @@ class Main {
      * @param initialBindings binding variables for the GroovyEngine
      * @return process exit code (0 for success)
      */
-    static int start(String[] args = new String[0], Map<String, ?> 
initialBindings = Collections.emptyMap()) {
+    static int start(Map<String, ?> initialBindings = Collections.emptyMap(), 
String[] args = new String[0]) {
         def cli = new CliBuilderInternal(usage: 'groovysh [options] [...]', 
stopAtNonOption: false,
             header: messages['cli.option.header'])
         cli.with {
@@ -527,6 +527,16 @@ class Main {
         return 0
     }
 
+    /**
+     * Programmatic entry point for embedding groovysh.
+     *
+     * @param args CLI-like arguments (same as {@link #main(String[])}).
+     * @return process exit code (0 for success)
+     */
+    static int start(String[] args) {
+        start([:], args)
+    }
+
     static void main(String[] args) {
         System.exit(start(args))
     }
diff --git 
a/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/ProgrammaticStartTest.groovy
 
b/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/ProgrammaticStartTest.groovy
index e2542f0463..1ceeb318d2 100644
--- 
a/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/ProgrammaticStartTest.groovy
+++ 
b/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/ProgrammaticStartTest.groovy
@@ -27,7 +27,9 @@ class ProgrammaticStartTest extends GroovyTestCase {
 
     void testStartMethodIsPresentAndCallable() {
         // We just verify it accepts parameters and doesn't throw on trivial 
help/version paths.
-        int rc = Main.start(['--help'] as String[], [foo: 1])
+        int rc = Main.start(foo: 1, '--help')
+        assert rc == 0
+        rc = Main.start('--version')
         assert rc == 0
     }
 }

Reply via email to