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 d1ddfadcaec003893ccd182927bd83c8ddfe0ef7 Author: Paul King <pa...@asert.com.au> AuthorDate: Wed Jul 16 14:27:00 2025 +1000 GROOVY-8162: Update Groovysh to JLine3 (start updating documentation) --- .../groovy-groovysh/src/spec/doc/groovysh.adoc | 46 ++++++++++++---------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc b/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc index 9da559e465..72bda7d2ed 100644 --- a/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc +++ b/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc @@ -23,6 +23,8 @@ == Groovy : Groovy Shell +NOTE: The groovysh is undergoing a major re-vamp and some of this information may not yet have been updated to reflect the latest changes. + The Groovy Shell, aka. `groovysh` is a command-line application which allows easy access to evaluate Groovy expressions, define classes and run simple experiments. @@ -30,9 +32,8 @@ run simple experiments. [[GroovyShell-Features]] === Features -* No need for `go` command to execute buffer. -* Rich cross-platform edit-line editing, history and completion thanks -to https://github.com/jline/jline2[JLine2]. +* Rich cross-platform line editing, history and completion thanks +to https://github.com/jline/jline3[JLine3]. * ANSI colors (prompt, exception traces, etc). * Simple, yet robust, command system with online help, user alias support and more. @@ -44,7 +45,7 @@ support and more. The shell supports several options to control verbosity, ANSI coloring and other features. -[source,groovy] +[source,shell] ----------------------------------------------------------------- ./bin/groovysh --help @@ -76,9 +77,10 @@ experiments. [[GroovyShell-SimpleExpressions]] ==== Simple Expressions -[source,groovy] +[source,jshell] --------------- -println "Hello" +groovy> println "Hello" +Hello --------------- [[GroovyShell-EvaluationResult]] @@ -97,22 +99,23 @@ complete expression it will compile and evaluate it. [[GroovyShell-DefineaClass]] ===== Define a Class -[source,groovy] +[source,jshell] --------------------- -class Foo { - def bar() { - println "baz" - } -} +groovy> class Foo { +add: } > def bar() { +add: }}> println "baz" +add: }}> } +add: } > } --------------------- [[GroovyShell-UsetheClass]] ===== Use the Class -[source,groovy] +[source,jshell] --------------- -foo = new Foo() -foo.bar() +groovy> foo = new Foo() +groovy> foo.bar() +baz --------------- [[GroovyShell-Variables]] @@ -143,18 +146,19 @@ Functions can be defined in the shell, and will be saved for later use. Defining a function is easy: -[source,groovy] +[source,jshell] ---------------------------------- -groovy:000> def hello(name) { -groovy:001> println("Hello $name") -groovy:002> } +groovy> def hello(name) { +add: }> println("Hello $name") +add: }> } ---------------------------------- And then using it is as one might expect: -[source,groovy] +[source,jshell] -------------- -hello("Jason") +groovy> hello "Jason" +Hello Jason -------------- Internally the shell creates a closure to encapsulate the function and