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 e5caaa0dc64b20492a5516805472346091ef14e8 Author: Paul King <[email protected]> AuthorDate: Sat Aug 2 10:55:03 2025 +1000 GROOVY-8162: Update Groovysh to JLine3 (additional documentation) --- .../src/spec/doc/assets/img/repl_echo.png | Bin 0 -> 169459 bytes .../src/spec/doc/assets/img/repl_import.png | Bin 0 -> 103944 bytes .../src/spec/doc/assets/img/repl_prnt.png | Bin 0 -> 227133 bytes .../src/spec/doc/assets/img/repl_typedef.png | Bin 0 -> 44076 bytes .../groovy-groovysh/src/spec/doc/groovysh.adoc | 45 +++++++++++++++++---- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_echo.png b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_echo.png new file mode 100644 index 0000000000..ff32c714bf Binary files /dev/null and b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_echo.png differ diff --git a/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_import.png b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_import.png new file mode 100644 index 0000000000..61e0615976 Binary files /dev/null and b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_import.png differ diff --git a/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_prnt.png b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_prnt.png new file mode 100644 index 0000000000..f3088e29e7 Binary files /dev/null and b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_prnt.png differ diff --git a/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_typedef.png b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_typedef.png new file mode 100644 index 0000000000..079bfa3294 Binary files /dev/null and b/subprojects/groovy-groovysh/src/spec/doc/assets/img/repl_typedef.png differ diff --git a/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc b/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc index bb1998e8e9..319b3eb8a0 100644 --- a/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc +++ b/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc @@ -99,6 +99,8 @@ complete expression it will compile and evaluate it. [[GroovyShell-DefineaClass]] ===== Define a Class +You can define all the normal types, e.g. a class: + [source,jshell] --------------------- groovy> class Foo { @@ -108,8 +110,7 @@ add: }}> } add: } > } --------------------- -[[GroovyShell-UsetheClass]] -===== Use the Class +And use it in the normal way. [source,jshell] --------------- @@ -118,6 +119,12 @@ groovy> foo.bar() baz --------------- +Defined classes are known to the shell and can be used in completion: + +image:assets/img/repl_typedef.png[Define Class, width=60%] + +[[GroovyShell-VariablesandMethods]] + [[GroovyShell-Variables]] ==== Variables @@ -139,10 +146,10 @@ def foo = "bar" This behavior can be changed by activating <<GroovyShell-InterpreterMode,interpreter mode>>. -[[GroovyShell-Functions]] -==== Functions +[[GroovyShell-Methods]] +==== Methods -Functions can be defined in the shell, and will be saved for later use. +Methods can be defined in the shell, and will be saved for later use. Defining a function is easy: @@ -251,6 +258,15 @@ This is the *only* way to exit the shell. Well, you can still `CTRL-Z` on unix p but things like `CTRL_C` are trapped. (See JLine3 documentation for more details.) [[GroovyShell-echo]] +===== `/echo` + +The `/echo` command outputs its arguments to the console. Arguments are output verbatim, +but variable expansion is also supported. + +image:assets/img/repl_echo.png[Echo, width=60%] + +See also the `/prnt` command, which is similar but may perform additional formatting +on the output(s). [[GroovyShell-import]] ===== `import` @@ -277,6 +293,10 @@ ArrayBlockingQueue ConcurrentSkipListSet ForkJoinTask ... -------------- +Once an import statement has been executed, relevant classes will become available for completion: + +image:assets/img/repl_import.png[Import, width=80%] + [[GroovyShell-imports]] ===== `/imports` @@ -341,7 +361,7 @@ groovy:003> :display ----------------------- [[GroovyShell-clear]] -===== `clear` +===== `/clear` Clears the current buffer, resetting the prompt counter to 000. Can be used to recover from compilation errors. @@ -371,8 +391,19 @@ Variables: [[GroovyShell-showall]] `show all` +[[GroovyShell-prnt]] +===== `/prnt` + +The `/prnt` command outputs its argument to the console. Both variable expansion +and formatting are supported. + +image:assets/img/repl_prnt.png[Echo, width=60%] + +See also the `/echo` command, which is similar but takes multiple arguments. +It also supports variable expansion but doesn't support formatting. + [[GroovyShell-inspect]] -===== `inspect` +===== `/inspect` Opens the GUI object browser to inspect a variable or the result of the last evaluation.
