第 1 章 起步
1.2 管理多个版本的 Groovy
参考笔记 SDKMAN Practice
$ sdk install groovy 2.4.1
1.3 使用 groovysh
打开交互式终端
$ groovysh
Groovy Shell (2.1.1, JVM: 1.7.0_141)
Type 'help' or '\h' for help.
groovy:000> help
For information about Groovy, visit:
http://groovy.codehaus.org
Available commands:
help (\h ) Display this help message
? (\? ) Alias to: help
exit (\x ) Exit the shell
quit (\q ) Alias to: exit
import (\i ) Import a class into the namespace
display (\d ) Display the current buffer
clear (\c ) Clear the buffer and reset the prompt counter.
show (\S ) Show variables, classes or imports
inspect (\n ) Inspect a variable or the last result with the GUI object browser
purge (\p ) Purge variables, classes, imports or preferences
edit (\e ) Edit the current buffer
load (\l ) Load a file or URL into the buffer
. (\. ) Alias to: load
save (\s ) Save the current buffer to a file
record (\r ) Record the current session to a file
history (\H ) Display, manage and recall edit-line history
alias (\a ) Create an alias
set (\= ) Set (or list) preferences
register (\rc) Registers a new command with the shell
For help on a specific command type:
help command
1.5 在命令行中运行 Groovy
$ cat Hello.groovy
println "Hello Groovy!"
$ groovy Hello.groovy
Hello Groovy!
在命令行中直接运行一些语句
$ groovy -e "println 'hello'"
hello
网友评论