You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2025/06/23 04:36:46 UTC

(groovy) branch jline3 updated: spike for JLine3 version of Groovysh

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

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


The following commit(s) were added to refs/heads/jline3 by this push:
     new 31e8f92fae spike for JLine3 version of Groovysh
31e8f92fae is described below

commit 31e8f92fae258e72115079ca48eaa6b36d55f9ae
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Jun 23 14:36:37 2025 +1000

    spike for JLine3 version of Groovysh
---
 .../{ClearCommand.groovy => ResetCommand.groovy}   | 12 ++++------
 .../groovy/groovysh/jline/GroovyBuiltins.groovy}   | 27 ++++++++++++++--------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ClearCommand.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ResetCommand.groovy
similarity index 85%
rename from subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ClearCommand.groovy
rename to subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ResetCommand.groovy
index d30d50a7f6..19139ea605 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ClearCommand.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ResetCommand.groovy
@@ -22,21 +22,19 @@ import org.apache.groovy.groovysh.CommandSupport
 import org.apache.groovy.groovysh.Groovysh
 
 /**
- * The 'clear' command.
+ * The 'reset' command.
  */
-class ClearCommand extends CommandSupport {
-    public static final String COMMAND_NAME = ':clear'
+class ResetCommand extends CommandSupport {
+    public static final String COMMAND_NAME = ':reset'
 
-    ClearCommand(final Groovysh shell) {
-        super(shell, COMMAND_NAME, ':c')
+    ResetCommand(final Groovysh shell) {
+        super(shell, COMMAND_NAME, ':R')
     }
 
     @Override
     Object execute(final List<String> args) {
         assertNoArguments(args)
-
         buffer.clear()
-
         if (io.verbose) {
             io.out.println('Buffer cleared') //  TODO: i18n
         }
diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/ClearCommandTest.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
similarity index 57%
rename from subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/ClearCommandTest.groovy
rename to subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
index b13fa914c5..e7e5ae47c5 100644
--- a/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/ClearCommandTest.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyBuiltins.groovy
@@ -16,17 +16,26 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.groovy.groovysh.commands
+package org.apache.groovy.groovysh.jline
 
-/**
- * Tests for the {@link ClearCommand} class.
- */
-class ClearCommandTest extends CommandTestSupport {
-    void testClear() {
-        shell.execute(ClearCommand.COMMAND_NAME)
+import org.jline.builtins.ConfigurationPath
+import org.jline.console.impl.Builtins
+import org.jline.reader.Widget
+
+import java.nio.file.Path
+import java.util.function.Function
+import java.util.function.Supplier
+
+class GroovyBuiltins extends Builtins {
+    GroovyBuiltins(Supplier<Path> workDir, ConfigurationPath configPath, Function<String, Widget> widgetCreator) {
+        super(workDir, configPath, widgetCreator)
+        commandNames().each{ name ->
+            rename(Command."${name.toUpperCase()}", "/$name")
+        }
     }
 
-    void testClearWithArgs() {
-        shell.execute(ClearCommand.COMMAND_NAME + ' foo')
+    @Override
+    String name() {
+        'Console Commands'
     }
 }