groovy.ui
Class GroovyMain

java.lang.Object
  extended by groovy.ui.GroovyMain

public class GroovyMain
extends java.lang.Object

A Command line to execute groovy.

Version:
$Revision: 12135 $
Author:
Jeremy Rayner, Yuri Schimke

Field Summary
private  java.util.List args
           
private  boolean autoOutput
           
private  boolean autoSplit
           
private  java.lang.String backupExtension
           
private  CompilerConfiguration conf
           
private  boolean debug
           
private  boolean editFiles
           
private  boolean isScriptFile
           
private  int port
           
private  boolean processFiles
           
private  boolean processSockets
           
private  java.lang.String script
           
private  java.lang.String splitPattern
           
 
Constructor Summary
GroovyMain()
           
 
Method Summary
private static org.apache.commons.cli.Options buildOptions()
          Build the options parser.
 java.io.File huntForTheScriptFile(java.lang.String input)
          Hunt for the script file, doesn't bother if it is named precisely.
static void main(java.lang.String[] args)
          Main CLI interface.
private static org.apache.commons.cli.CommandLine parseCommandLine(org.apache.commons.cli.Options options, java.lang.String[] args)
          Parse the command line.
private static void printHelp(java.io.PrintStream out, org.apache.commons.cli.Options options)
           
private static boolean process(org.apache.commons.cli.CommandLine line)
          Process the users request.
(package private) static void processArgs(java.lang.String[] args, java.io.PrintStream out)
           
private  void processFile(Script s, java.io.File file)
          Process a single input file.
private  void processFiles()
          Process the input files.
private  void processOnce()
          Process the standard, single script with args.
private  void processReader(Script s, java.io.BufferedReader reader, java.io.PrintWriter pw)
          Process a script against a single input file.
private  void processSockets()
          Process Sockets.
private  boolean run()
          Run the script.
private static void setSystemPropertyFrom(java.lang.String nameValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

args

private java.util.List args

isScriptFile

private boolean isScriptFile

script

private java.lang.String script

processFiles

private boolean processFiles

editFiles

private boolean editFiles

autoOutput

private boolean autoOutput

autoSplit

private boolean autoSplit

splitPattern

private java.lang.String splitPattern

processSockets

private boolean processSockets

port

private int port

backupExtension

private java.lang.String backupExtension

debug

private boolean debug

conf

private CompilerConfiguration conf
Constructor Detail

GroovyMain

public GroovyMain()
Method Detail

main

public static void main(java.lang.String[] args)
Main CLI interface.

Parameters:
args - all command line args.

processArgs

static void processArgs(java.lang.String[] args,
                        java.io.PrintStream out)

printHelp

private static void printHelp(java.io.PrintStream out,
                              org.apache.commons.cli.Options options)

parseCommandLine

private static org.apache.commons.cli.CommandLine parseCommandLine(org.apache.commons.cli.Options options,
                                                                   java.lang.String[] args)
                                                            throws org.apache.commons.cli.ParseException
Parse the command line.

Parameters:
options - the options parser.
args - the command line args.
Returns:
parsed command line.
Throws:
org.apache.commons.cli.ParseException - if there was a problem.

buildOptions

private static org.apache.commons.cli.Options buildOptions()
Build the options parser. Has to be synchronized because of the way Options are constructed.

Returns:
an options parser.

setSystemPropertyFrom

private static void setSystemPropertyFrom(java.lang.String nameValue)

process

private static boolean process(org.apache.commons.cli.CommandLine line)
                        throws org.apache.commons.cli.ParseException
Process the users request.

Parameters:
line - the parsed command line.
Throws:
org.apache.commons.cli.ParseException - if invalid options are chosen

run

private boolean run()
Run the script.


processSockets

private void processSockets()
                     throws CompilationFailedException,
                            java.io.IOException
Process Sockets.

Throws:
CompilationFailedException
java.io.IOException

huntForTheScriptFile

public java.io.File huntForTheScriptFile(java.lang.String input)
Hunt for the script file, doesn't bother if it is named precisely. Tries in this order: - actual supplied name - name.groovy - name.gvy - name.gy - name.gsh


processFiles

private void processFiles()
                   throws CompilationFailedException,
                          java.io.IOException
Process the input files.

Throws:
CompilationFailedException
java.io.IOException

processFile

private void processFile(Script s,
                         java.io.File file)
                  throws java.io.IOException
Process a single input file.

Parameters:
s - the script to execute.
file - the input file.
Throws:
java.io.IOException

processReader

private void processReader(Script s,
                           java.io.BufferedReader reader,
                           java.io.PrintWriter pw)
                    throws java.io.IOException
Process a script against a single input file.

Parameters:
s - script to execute.
reader - input file.
pw - output sink.
Throws:
java.io.IOException

processOnce

private void processOnce()
                  throws CompilationFailedException,
                         java.io.IOException
Process the standard, single script with args.

Throws:
CompilationFailedException
java.io.IOException


Copyright © ${year} The Codehaus. All Rights Reserved.