de.caff.util.args

## Class CommandLine

- java.lang.Object
- - de.caff.util.args.CommandLine

-     public class CommandLine
      extends java.lang.Object

  Application command-line helper.
  Since:
    January 27, 2019
  Author:
    Rammi

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `LONG_ARG_SEP`
    `static char` | `NON_BREAKING_SPACE`
    `static java.lang.String` | `PREFIX_LONG`
    `static java.lang.String` | `PREFIX_SHORT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CommandLine(java.lang.Iterable<SwitchOrArgument> switchesOrArguments)` Constructor.
    `CommandLine(SwitchOrArgument... switchesOrArguments)` Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `checkLongForm(java.lang.String longForm)`
    `void` | `evaluate(java.util.List<java.lang.String> args)` Evaluate the command line.
    `void` | `evaluate(java.lang.String[] args)` Evaluate the command line.
    `java.lang.String` | `getUsage(int lineLength, int indent)`
    `void` | `printUsageAndExit(int exitCode)`
    `void` | `printUsageAndExit(java.io.PrintStream out, int exitCode)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### PREFIX_SHORT

          public static final java.lang.String PREFIX_SHORT

      See Also:
        Constant Field Values

    - #### PREFIX_LONG

          public static final java.lang.String PREFIX_LONG

      See Also:
        Constant Field Values

    - #### LONG_ARG_SEP

          public static final java.lang.String LONG_ARG_SEP

      See Also:
        Constant Field Values

    - #### NON_BREAKING_SPACE

          public static final char NON_BREAKING_SPACE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CommandLine

          public CommandLine(@NotNull
                             SwitchOrArgument... switchesOrArguments)

      Constructor.
      Parameters:
        `switchesOrArguments` - switches or arguments used on the command line

    - #### CommandLine

          public CommandLine(@NotNull
                             java.lang.Iterable<SwitchOrArgument> switchesOrArguments)

      Constructor.
      Parameters:
        `switchesOrArguments` - switches or arguments used on the command line

  - ### Method Detail

    - #### evaluate

          public void evaluate(@NotNull
                               java.lang.String[] args)
                        throws UnknownSwitchException,
                               UnexpectedArgumentException,
                               TooManyArgumentsException,
                               MissingSwitchArgumentException

      Evaluate the command line.
      Parameters:
        `args` - command line arguments
      Throws:
        `UnknownSwitchException` - if an unknown switch appears
        `UnexpectedArgumentException` - if a long switch not requiring an argument comes with an argument
        `TooManyArgumentsException` - if there are no more switches or arguments for consuming the command line args
        `MissingSwitchArgumentException` - if there are not enough arguments for a switch

    - #### evaluate

          public void evaluate(@NotNull
                               java.util.List<java.lang.String> args)
                        throws UnknownSwitchException,
                               UnexpectedArgumentException,
                               TooManyArgumentsException,
                               MissingSwitchArgumentException

      Evaluate the command line.
      Parameters:
        `args` - command line arguments
      Throws:
        `UnknownSwitchException` - if an unknown switch appears
        `UnexpectedArgumentException` - if a long switch not requiring an argument comes with an argument
        `TooManyArgumentsException` - if there are no more switches or arguments for consuming the command line args
        `MissingSwitchArgumentException` - ifa required switch is not present

    - #### checkLongForm

          public static void checkLongForm(@NotNull
                                           java.lang.String longForm)

    - #### getUsage

          @NotNull
          public java.lang.String getUsage(int lineLength,
                                                    int indent)

    - #### printUsageAndExit

          public void printUsageAndExit(@NotNull
                                        java.io.PrintStream out,
                                        int exitCode)

    - #### printUsageAndExit

          public void printUsageAndExit(int exitCode)