Griffon 1.2.0

org.codehaus.griffon.cli
[Groovy] Class CommandLineHelper

java.lang.Object
  org.codehaus.griffon.cli.CommandLineHelper

class CommandLineHelper

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

Authors:
Graeme Rocher (Grails 1.2)


Field Summary
private PrintStream out

 
Constructor Summary
CommandLineHelper()

CommandLineHelper(PrintStream out)

 
Method Summary
String askAndDo(String message, Closure yesCallback = null, Closure noCallback = null)

boolean confirmInput(String msg)

String forceUserInput(String message)

String forceUserInput(String message, String[] validResponses)

private ConfigObject getConfig()

String getDefaultAnswerNonInteractive()

String userInput(String message)

Replacement for AntBuilder.input() to eliminate dependency of GriffonScriptRunner on the Ant libraries.

String userInput(String message, String[] validResponses)

Replacement for AntBuilder.input() to eliminate dependency of GriffonScriptRunner on the Ant libraries.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

out

private PrintStream out


 
Constructor Detail

CommandLineHelper

CommandLineHelper()


CommandLineHelper

CommandLineHelper(PrintStream out)


 
Method Detail

askAndDo

String askAndDo(String message, Closure yesCallback = null, Closure noCallback = null)


confirmInput

boolean confirmInput(String msg)


forceUserInput

String forceUserInput(String message)


forceUserInput

String forceUserInput(String message, String[] validResponses)


getConfig

private ConfigObject getConfig()


getDefaultAnswerNonInteractive

String getDefaultAnswerNonInteractive()


userInput

String userInput(String message)
Replacement for AntBuilder.input() to eliminate dependency of GriffonScriptRunner 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

String userInput(String message, String[] validResponses)
Replacement for AntBuilder.input() to eliminate dependency of GriffonScriptRunner 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.


 

Groovy Documentation