Repository: incubator-groovy Updated Branches: refs/heads/master 2f5cf976b -> 8b737a11c
draft doco for groovy commandline Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/8b737a11 Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/8b737a11 Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/8b737a11 Branch: refs/heads/master Commit: 8b737a11c1b3221105baa7d6d650835e43b6a2b0 Parents: 2f5cf97 Author: Paul King <pa...@asert.com.au> Authored: Thu May 14 11:12:15 2015 +1000 Committer: Paul King <pa...@asert.com.au> Committed: Thu May 14 11:12:15 2015 +1000 ---------------------------------------------------------------------- src/spec/doc/index.adoc | 2 ++ src/spec/doc/tools-groovy.adoc | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/8b737a11/src/spec/doc/index.adoc ---------------------------------------------------------------------- diff --git a/src/spec/doc/index.adoc b/src/spec/doc/index.adoc index fef4556..4a6b70b 100644 --- a/src/spec/doc/index.adoc +++ b/src/spec/doc/index.adoc @@ -20,6 +20,8 @@ include::{projectdir}/src/spec/doc/core-semantics.adoc[leveloffset=+2] == Tools +include::{projectdir}/src/spec/doc/tools-groovy.adoc[leveloffset=+2] + include::{projectdir}/src/spec/doc/tools-groovyc.adoc[leveloffset=+2] include::{projectdir}/subprojects/groovy-groovysh/{specfolder}/groovysh.adoc[leveloffset=+2] http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/8b737a11/src/spec/doc/tools-groovy.adoc ---------------------------------------------------------------------- diff --git a/src/spec/doc/tools-groovy.adoc b/src/spec/doc/tools-groovy.adoc new file mode 100644 index 0000000..a13487b --- /dev/null +++ b/src/spec/doc/tools-groovy.adoc @@ -0,0 +1,41 @@ += Running Groovy from the commandline + +[[section-groovy-commandline]] +== groovy, the Groovy command + +`groovy` invokes the Groovy command line processor. It allows you to run inline Groovy expressions, and scripts, tests or application within groovy files. +It plays a similar role to `java` in the Java world but handles inline scripts and rather than invoking class files, it is normally called with scripts +and will automatically call the Groovy compiler as needed. + +The easiest way to run a Groovy script, test or application is to run the following command at your shell prompt: + +------------------------ +> groovy MyScript.groovy +------------------------ + +The `.groovy` part is optional. The `groovy` command supports a number of command line switches: + +[cols="<,<,<,<",options="header,footer"] +|======================================================================= +|Short version |Long version |Description |Example +| -a | --autosplit <splitPattern> | split lines using splitPattern (default '\s') using implicit 'split' variable | +| -b | --basescript <class> | Base class name for scripts (must derive from Script) | +| -c | --encoding <charset> | specify the encoding of the files | +| -cp <path> | -classpath <path> + +--classpath <path> | Specify the compilation classpath. Must be the first argument. | groovy -cp lib/dep.jar MyScript +| | --configscript <path> | Advanced compiler configuration script | groovy --configscript config/config.groovy src/Person.groovy +| -D | --define <name=value> | define a system property | +| -d | --debug | debug mode will print out full stack traces | +| | --disableopt <optlist> | disables one or all optimization elements. + +optlist can be a comma separated list with the elements: + +all (disables all optimizations), + +int (disable any int based optimizations) | +| -e <script> | | specify an inline command line script | groovy -e "println new Date()" +| -h | --help | Displays usage information for the command line groovy command | groovy --help +| -i <extension> | | modify files in place; create backup if extension is given (e.g. '.bak') | +| | --indy | Enables invokedynamic support. Requires Java 7+ | groovy --indy Person.groovy +| -l <port> | | listen on a port and process inbound lines (default: 1960) | +| -n | | process files line by line using implicit 'line' variable | +| -p | | process files line by line and print result (see also -n) | +| -v | --version | display the Groovy and JVM versions | groovy -v +|=======================================================================