The shell supports several options to control verbosity, ANSI coloring and other features:
casiano@millo:~/src/groovy$ groovysh --help usage: groovysh [options] [...] -C, --color[=FLAG] Enable or disable use of ANSI colors -D, --define=NAME=VALUE Define a system property -T, --terminal=TYPE Specify the terminal TYPE to use -V, --version Display the version -d, --debug Enable debug output -h, --help Display this help message -q, --quiet Suppress superfluous output -v, --verbose Enable verbose output
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.
Sigue un ejemplo de ejecución de un comando:
casiano@millo:~/src/groovy$ groovysh 'show preferences' No preferences are set
Sigue un ejemplo de evaluación de una expresión:
casiano@tonga:~/src/groovy$ groovysh 'System.properties.each { k, v -> println("$k = $v") }' java.runtime.name = OpenJDK Runtime Environment sun.boot.library.path = /usr/lib/jvm/java-6-openjdks/jre/lib/i386 java.vm.version = 1.6.0_0-b11 java.vm.vendor = Sun Microsystems Inc. java.vendor.url = http://java.sun.com/ path.separator = : java.vm.name = OpenJDK Client VM file.encoding.pkg = sun.io sun.java.launcher = SUN_STANDARD user.country = US sun.os.patch.level = unknown program.name = groovysh java.vm.specification.name = Java Virtual Machine Specification user.dir = /home/casiano/src/groovy java.runtime.version = 1.6.0_0-b11 java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment java.endorsed.dirs = /usr/lib/jvm/java-6-openjdks/jre/lib/endorsed os.arch = i386 javax.accessibility.assistive_technologies = org.GNOME.Accessibility.JavaBridge java.io.tmpdir = /tmp line.separator = .....