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

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

commit 19f96256db08ae037e2bab89b21ba14344d2ad9f
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Aug 10 13:42:56 2025 +1000

    GROOVY-8162: Update Groovysh to JLine3 (improve help output for /nano and 
/less)
---
 .../groovy/groovysh/jline/GroovyBuiltins.groovy    | 36 +++++++++++++---------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
index 7d63f72b93..b634448ba2 100644
--- 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
+++ 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
@@ -57,14 +57,17 @@ class GroovyBuiltins extends Builtins {
     }
 
     private void less(CommandInput input) {
-        Options opt = Options.compile(Less.usage()).parse(input.args())
-        boolean usingBuffer = opt.args().size() == 0
-        if (usingBuffer) {
-            def temp = File.createTempFile('groovysh', '.groovy')
-            temp.text = engine.buffer
-            input = new CommandInput(input.command(), [*input.args(), 
temp.absolutePath] as String[], input.terminal(), input.in(), input.out(), 
input.err())
-        }
+        Options opt = Options.compile(*Less.usage()*.replaceAll('less ', 
'/less ')).parse(input.args())
         try {
+            if (opt.isSet("help")) {
+                throw new Options.HelpException(opt.usage());
+            }
+            boolean usingBuffer = opt.args().size() == 0
+            if (usingBuffer) {
+                def temp = File.createTempFile('groovysh', '.groovy')
+                temp.text = engine.buffer
+                input = new CommandInput(input.command(), [*input.args(), 
temp.absolutePath] as String[], input.terminal(), input.in(), input.out(), 
input.err())
+            }
             Commands.less(input.terminal(), input.in(), input.out(), 
input.err(), workDir.get(), input.xargs(), configPath)
         } catch (Exception e) {
             saveException(e)
@@ -72,15 +75,18 @@ class GroovyBuiltins extends Builtins {
     }
 
     private void nano(CommandInput input) {
-        Options opt = Options.compile(Nano.usage()).parse(input.args())
-        boolean usingBuffer = opt.args().size() == 0
-        def temp = null
-        if (usingBuffer) {
-            temp = File.createTempFile('groovysh', '.groovy')
-            temp.text = engine.buffer
-            input = new CommandInput(input.command(), [*input.args(), 
temp.absolutePath] as String[], input.terminal(), input.in(), input.out(), 
input.err())
-        }
+        Options opt = Options.compile(*Nano.usage()*.replaceAll('nano ', 
'/nano ')).parse(input.args())
         try {
+            if (opt.isSet("help")) {
+                throw new Options.HelpException(opt.usage());
+            }
+            boolean usingBuffer = opt.args().size() == 0
+            def temp = null
+            if (usingBuffer) {
+                temp = File.createTempFile('groovysh', '.groovy')
+                temp.text = engine.buffer
+                input = new CommandInput(input.command(), [*input.args(), 
temp.absolutePath] as String[], input.terminal(), input.in(), input.out(), 
input.err())
+            }
             Commands.nano(input.terminal(), input.out(), input.err(), 
workDir.get(), input.args(), configPath)
             if (temp) GroovyCommands.loadFile(engine, temp)
         } catch (Exception e) {

Reply via email to