org.codehaus.groovy.grails.cli
Class CommandLineHelper

java.lang.Object
  extended by org.codehaus.groovy.grails.cli.CommandLineHelper

public class CommandLineHelper
extends Object

Contains static utility methods for use on the command line, including method to accept user input etc.

Since:
1.2
Author:
Graeme Rocher

Constructor Summary
CommandLineHelper()
           
CommandLineHelper(PrintStream out)
           
 
Method Summary
 String userInput(String message)
          Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries.
 String userInput(String message, String[] validResponses)
          Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineHelper

public CommandLineHelper()

CommandLineHelper

public CommandLineHelper(PrintStream out)
Method Detail

userInput

public String userInput(String message)
Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries. Prints a message and returns whatever the user enters (once they press <return>).

Parameters:
message - The message/question to display.
Returns:
The line of text entered by the user. May be a blank string.

userInput

public String userInput(String message,
                        String[] validResponses)
Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries. Prints a message and list of valid responses, then returns whatever the user enters (once they press <return>). If the user enters something that is not in the array of valid responses, the message is displayed again and the method waits for more input. It will display the message a maximum of three times before it gives up and returns null.

Parameters:
message - The message/question to display.
validResponses - An array of responses that the user is allowed to enter. Displayed after the message.
Returns:
The line of text entered by the user, or null if the user never entered a valid string.


Copyright (c) 2005-2009 The Grails project