The Groovy Shell, aka.
groovysh is a command-line application which allows easy access to evaluate Groovy expressions, define classes and run simple experiments.
- Command-line Options and Arguments
- Evaluating Expressions
- User Profile Scripts and State
- Screen Shots
- No need for
gocommand to execute buffer.
- Rich cross-platform edit-line editing, history and completion thanks to JLine.
- ANSI colors (prompt, exception traces, etc).
- Simple, yet robust, command system with online help, user alias support and more.
- User profile support
Command-line Options and Arguments
The shell supports several options to control verbosity, ANSI coloring and other features.
In addition to options, commands or expressions can be given on the command-line which will invoke the shell in non-interactive mode. The commands or expressions will be evaluated and the shell will exit. If no additional arguments are given the shell will startup interactively.
Execute a Command
Evaluate an Expression
When a complete expression is found, it is compiled and evaluated. The result of the evaluation is stored into the
Multi-line/complex expressions (like closure or class definitions) may be defined over several lines. When the shell detects that it has a complete expression it will compile and evaluate it.
Define a Class
Use the Class
The shell has a number of different commands, which provide rich access to the shell's environment.
Commands all have a name and a shortcut (which is something like
\h). Commands may also have some predefined system aliases. Users may also create their own aliases.
Display the list of commands (and aliases) or the help text for specific command.
The Command List
Help for a Command
While in the interactive shell, you can ask for help for any command to get more details about its syntax or function. Here is an example of what happens when you ask for help for the
Exit the shell.
Add a custom import which will be included for all shell evaluations.
Display the contents of the current buffer.
Clear the current buffer.
Show variables, classes or preferences or imports.
Opens the GUI object browser to inspect a variable or the result of the last evaluation.
Purges objects from the shell.
Edit the current buffer.
Load one or more files (or urls) into the buffer.
Saves the buffer's contents to a file.
Record the current session to a file.
Display, manage and recall edit-line history.
Create an alias.
Set or list preferences.
Some of aspects of
groovysh behaviors can be customized by setting preferences. Preferences are set using the
set command or the
Set the shell's verbosity level. Expected to be one of:
If this preference is set to an invalid value, then the previous setting will be used, or if there is none, then the preference is removed and the default is used.
Show the last result after an execution.
Sanitize (trim-down/filter) stack traces.
Setting a Preference
To list the current set preferences (and their values):
Clearing Preferences (ie. Resetting to Defaults)
User Profile Scripts and State
This script, if it exists, is loaded when the shell starts up.
This script, if it exists, is loaded when the shell enters interactive mode.
Edit-line history is stored in this file.
These shots have been taken over the development of the new shell, so some of the content might look slightly different. Also, note the yellow colors here are the shell's bold color, so the colors might look different depending on how the enclosing shell has its colors setup.