CommandLineParser (Grails 6.0.0)

Package: org.grails.build.parsing

## [Java] Class CommandLineParser

- org.grails.build.parsing.CommandLineParser

-     public class CommandLineParser
      extends java.lang.Object

  Command line parser that parses arguments to the command line. Written as a replacement for Commons CLI because it doesn't support unknown arguments and requires all arguments to be declared up front. It also doesn't support command options with hyphens. This class gets around those problems.

  Authors:
    Graeme Rocher
  Since:
    2.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static CommandLine` | `CURRENT` |
    `static java.util.Map<java.lang.String, java.lang.String>` | `DEFAULT_ENVS` |
    `private static java.lang.String` | `DEFAULT_PADDING` |
    `static java.util.Map<java.lang.String, java.lang.String>` | `ENV_ARGS` |
    `private java.util.Map<java.lang.String, Option>` | `declaredOptions` |
    `private int` | `longestOptionNameLength` |
    `private java.lang.String` | `usageMessage` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addOption(java.lang.String name, java.lang.String description)` Adds a declared option
    `` | `protected DefaultCommandLine` | `createCommandLine()`
    `` | `public static CommandLine` | `getCurrentCommandLine()`
    `` | `public java.lang.String` | `getOptionsHelpMessage()`
    `` | `public CommandLine` | `parse(java.lang.String args)` Parses the given list of command line arguments.
    `` | `public CommandLine` | `parse(DefaultCommandLine cl, java.lang.String[] args)`
    `` | `private void` | `parseInternal(DefaultCommandLine cl, java.lang.String[] args, boolean firstArgumentIsCommand)`
    `` | `public CommandLine` | `parseString(java.lang.String string)` Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args)
    `` | `public CommandLine` | `parseString(java.lang.String commandName, java.lang.String args)` Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args)
    `` | `protected java.lang.String` | `processOption(DefaultCommandLine cl, java.lang.String arg)`
    `` | `protected void` | `processSystemArg(DefaultCommandLine cl, java.lang.String arg)`
    `` | `public static java.lang.String[]` | `translateCommandline(java.lang.String toProcess)` Crack a command line.
    `` | `private void` | `validateOptionName(java.lang.String name)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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()`

- - ### Field Detail

    - #### private static CommandLine CURRENT

    - #### static java.util.Map<java.lang.String, java.lang.String> DEFAULT_ENVS

    - #### private static final java.lang.String DEFAULT_PADDING

    - #### static java.util.Map<java.lang.String, java.lang.String> ENV_ARGS

    - #### private java.util.Map<java.lang.String, Option> declaredOptions

    - #### private int longestOptionNameLength

    - #### private java.lang.String usageMessage

  - ### Method Detail

    - #### public void addOption(java.lang.String name, java.lang.String description)

      Adds a declared option

      Parameters:
        `name` - The name of the option
        `description` - The description

    - #### protected DefaultCommandLine createCommandLine()

    - #### public static CommandLine getCurrentCommandLine()

    - #### public java.lang.String getOptionsHelpMessage()

    - #### public CommandLine parse(java.lang.String args)

      Parses the given list of command line arguments. Arguments starting with -D become system properties, arguments starting with -- or - become either declared or undeclared options. All other arguments are put into a list of remaining arguments

      Parameters:
        `args` - The arguments
      Returns:
        The command line state

    - #### public CommandLine parse(DefaultCommandLine cl, java.lang.String[] args)

    - #### private void parseInternal(DefaultCommandLine cl, java.lang.String[] args, boolean firstArgumentIsCommand)

    - #### public CommandLine parseString(java.lang.String string)

      Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args)

      Parameters:
        `string` - The string
      Returns:
        The command line

    - #### public CommandLine parseString(java.lang.String commandName, java.lang.String args)

      Parses a string of all the command line options converting them into an array of arguments to pass to #parse(String..args)

      Parameters:
        `commandName` - The command name
        `args` - The string
      Returns:
        The command line

    - #### protected java.lang.String processOption(DefaultCommandLine cl, java.lang.String arg)

    - #### protected void processSystemArg(DefaultCommandLine cl, java.lang.String arg)

    - #### public static java.lang.String[] translateCommandline(java.lang.String toProcess)

      Crack a command line.

      Parameters:
        `toProcess` - the command line to process.
      Returns:
        the command line broken into strings. An empty or null toProcess parameter results in a zero sized array.

    - #### private void validateOptionName(java.lang.String name)