Package: org.codehaus.groovy.grails.cli

## [Java] Class CommandLineHelper

- org.codehaus.groovy.grails.cli.CommandLineHelper

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

  Authors:
    Graeme Rocher
  Since:
    1.2

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CommandLineHelper ()`
    `CommandLineHelper (java.io.PrintStream out)` @deprecated Use no-args constructor
    `CommandLineHelper (java.io.InputStream input, java.io.PrintStream out)` @deprecated Use no-args constructor

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `java.lang.String` | `userInput(java.lang.String message)` Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries.
    `java.lang.String` | `userInput(java.lang.String message, java.lang.String[] validResponses)` Replacement for AntBuilder.input() to eliminate dependency of GrailsScriptRunner on the Ant libraries.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### public CommandLineHelper()

    - #### @java.lang.Deprecated public CommandLineHelper(java.io.PrintStream out)

      deprecated:
        Use no-args constructor

    - #### @java.lang.Deprecated public CommandLineHelper(java.io.InputStream input, java.io.PrintStream out)

      deprecated:
        Use no-args constructor

  - ### Method Detail

    - #### public java.lang.String userInput(java.lang.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.

    - #### public java.lang.String userInput(java.lang.String message, java.lang.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.