|
|||||
FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A simple interactive shell for evaluating groovy expressions on the command line (aka. groovysh).
Field Summary | |
---|---|
def |
COMMANDS
|
Map |
COMMAND_HELP
|
int |
COMMAND_ID_BINDING
|
int |
COMMAND_ID_DISCARD
|
int |
COMMAND_ID_DISCARD_LOADED_CLASSES
|
int |
COMMAND_ID_DISPLAY
|
int |
COMMAND_ID_EXECUTE
|
int |
COMMAND_ID_EXIT
|
int |
COMMAND_ID_EXPLAIN
|
int |
COMMAND_ID_HELP
|
int |
COMMAND_ID_INSPECT
|
Map |
COMMAND_MAPPINGS
|
int |
LAST_COMMAND_ID
|
MessageSource |
MESSAGES
|
String |
NEW_LINE
|
StringBuffer |
accepted
|
Closure |
afterExecution
|
Closure |
beforeExecution
|
PrintStream |
err
|
Exception |
error
|
InputStream |
in
|
Object |
lastResult
|
int |
line
|
PrintStream |
out
|
SourceUnit |
parser
|
String |
pending
|
ConsoleReader |
reader
|
GroovyShell |
shell
|
boolean |
stale
|
Constructor Summary | |
InteractiveShell()
Default constructor, initializes uses new binding and system streams. |
|
InteractiveShell(InputStream in, PrintStream out, PrintStream err)
Constructs a new InteractiveShell instance |
|
InteractiveShell(Binding binding, InputStream in, PrintStream out, PrintStream err)
Constructs a new InteractiveShell instance |
|
InteractiveShell(ClassLoader parent, Binding binding, InputStream in, PrintStream out, PrintStream err)
Constructs a new InteractiveShell instance |
Method Summary | |
---|---|
void |
accept()
Accepts the pending text into the statement. |
String |
accepted(boolean complete)
Returns the accepted statement as a string. |
String |
current()
Returns the current statement, including pending text. |
void |
displayBinding()
Displays the current binding used when instanciating the shell. |
void |
displayHelp()
Displays help text about available commands. |
void |
displayStatement()
Displays the accepted statement. |
void |
explainStatement()
Attempts to parse the accepted statement and display the parse tree for it. |
void |
filterAndPrintStackTrace(Throwable cause)
Filter stacktraces to show only relevant lines of the exception thrown. |
void |
freshen()
Clears accepted if stale. |
void |
inspect()
|
static void |
main(def args)
Entry point when called directly. |
boolean |
parse(String code, int tolerance)
Attempts to parse the specified code with the specified tolerance. |
boolean |
parse(String code)
|
static void |
processCommandLineArguments(def args)
Process cli args when the shell is invoked via main(). |
String |
read()
Reads a single statement from the command line. |
void |
report()
Reports the last parsing error to the user. |
void |
reset()
The statement text accepted to date |
void |
resetLoadedClasses()
|
void |
run()
Reads commands and statements from input stream and processes them. |
void |
setAfterExecution(Closure afterExecution)
A closure that is executed after the execution of the last script. |
void |
setBeforeExecution(Closure beforeExecution)
A closure that is executed before the exection of a given script |
Constructor Detail |
---|
public InteractiveShell()
public InteractiveShell(InputStream in, PrintStream out, PrintStream err)
public InteractiveShell(Binding binding, InputStream in, PrintStream out, PrintStream err)
public InteractiveShell(ClassLoader parent, Binding binding, InputStream in, PrintStream out, PrintStream err)
Method Detail |
---|
void accept()
String accepted(boolean complete)
String current()
void displayBinding()
void displayHelp()
void displayStatement()
void explainStatement()
void filterAndPrintStackTrace(Throwable cause)
void freshen()
void inspect()
public static void main(def args)
boolean parse(String code, int tolerance)
parser
and error
members
appropriately. Returns true if the text parsed, false otherwise.
The attempts to identify and suppress errors resulting from the
unfinished source text.
boolean parse(String code)
static void processCommandLineArguments(def args)
String read()
void report()
void reset()
void resetLoadedClasses()
public void run()
public void setAfterExecution(Closure afterExecution)
public void setBeforeExecution(Closure beforeExecution)