org.wildfly.swarm.cli

## Class CommandLine

- java.lang.Object
- - org.wildfly.swarm.cli.CommandLine

-     public class CommandLine
      extends Object

  A parsed command-line.
  Author:
    Bob McWhirter

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Option<String>` | `BIND` Default option for parsing -b
    `static Option<List<URL>>` | `CONFIG`
    `static Option<String>` | `CONFIG_HELP`
    `static Option<Boolean>` | `HELP` Default option for parsing -h and --help
    `static Option<List<String>>` | `PROFILES`
    `static Option<URL>` | `PROPERTIES_URL` Default option for parsing -P
    `static Option<Properties>` | `PROPERTY` Default option for parsing -Dname and -Dname=value
    `static Option<URL>` | `SERVER_CONFIG` Default option for parsing -c and --server-config
    `static Option<Boolean>` | `VERSION` Default option for parsing -v and --version
    `static Option<String>` | `YAML_HELP`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `apply(Swarm swarm)` Apply properties and configuration from the parsed commandline to a container.
    `void` | `applyConfigurations(Swarm swarm)` Apply configuration to the container.
    `void` | `applyProperties(Swarm swarm)` Apply properties to the system properties.
    `static Options` | `defaultOptions()` Default set of options
    `void` | `displayConfigHelp(PrintStream out, String fraction)`
    `void` | `displayHelp(PrintStream out)` Display help for the options associated with the creation of this command-line.
    `void` | `displayVersion(PrintStream out)` Display the version.
    `void` | `dumpYaml(PrintStream out, String fraction)`
    `List<String>` | `extraArguments()` Any un-parsed non-option arguments.
    `String[]` | `extraArgumentsArray()` Any un-parsed non-option arguments.
    `<T> T` | `get(Option<T> key)` Retrieve a value under a given key.
    `boolean` | `hasInvalidArguments()` Determine if any invalid arguments were seen during the parse.
    `List<String>` | `invalidArguments()` Any invalid options seen during parsing.
    `static CommandLine` | `parse(Options options, String... args)` Parse an array of arguments using specific options.
    `static CommandLine` | `parse(String... args)` Parse an array of arguments using the default options.
    `<T> void` | `put(Option<T> key, T value)` Put a value under a given key.

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

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

- - ### Field Detail

    - #### HELP

          public static final Option<Boolean> HELP

      Default option for parsing -h and --help

    - #### CONFIG_HELP

          public static final Option<String> CONFIG_HELP

    - #### YAML_HELP

          public static final Option<String> YAML_HELP

    - #### VERSION

          public static final Option<Boolean> VERSION

      Default option for parsing -v and --version

    - #### PROPERTY

          public static final Option<Properties> PROPERTY

      Default option for parsing -Dname and -Dname=value

    - #### PROPERTIES_URL

          public static final Option<URL> PROPERTIES_URL

      Default option for parsing -P

    - #### SERVER_CONFIG

          public static final Option<URL> SERVER_CONFIG

      Default option for parsing -c and --server-config

    - #### CONFIG

          public static final Option<List<URL>> CONFIG

    - #### PROFILES

          public static final Option<List<String>> PROFILES

    - #### BIND

          public static final Option<String> BIND

      Default option for parsing -b

  - ### Method Detail

    - #### defaultOptions

          public static Options defaultOptions()

      Default set of options

    - #### put

          public <T> void put(Option<T> key,
                              T value)

      Put a value under a given key.
      Type Parameters:
        `T` - The type of the value.
      Parameters:
        `key` - The key.
        `value` - The value.

    - #### get

          public <T> T get(Option<T> key)

      Retrieve a value under a given key.
      Type Parameters:
        `T` - The type of the value.
      Parameters:
        `key` - The key.
      Returns:
        The previously stored value, or the default provided by key if none has been previously stored. The default will then be stored.

    - #### displayHelp

          public void displayHelp(PrintStream out)

      Display help for the options associated with the creation of this command-line.
      Parameters:
        `out` - The output stream to display help upon.

    - #### displayConfigHelp

          public void displayConfigHelp(PrintStream out,
                                        String fraction)
                                 throws IOException,
                                        ModuleLoadException

      Throws:
        `IOException`
        `ModuleLoadException`

    - #### dumpYaml

          public void dumpYaml(PrintStream out,
                               String fraction)
                        throws IOException,
                               ModuleLoadException

      Throws:
        `IOException`
        `ModuleLoadException`

    - #### displayVersion

          public void displayVersion(PrintStream out)

      Display the version.
      Parameters:
        `out` - The output stream to display help upon.

    - #### applyProperties

          public void applyProperties(Swarm swarm)
                               throws IOException

      Apply properties to the system properties.

      Applies values stored through the `Key.PROPERTIES`, `Key.PROPERTIES_URL` or `Key.BIND` options.

      Throws:
        `IOException` - If a URL is attempted to be read and fails.

    - #### applyConfigurations

          public void applyConfigurations(Swarm swarm)
                                   throws IOException

      Apply configuration to the container.

      Applies configuration from `Key.SERVER_CONFIG` and `Key.STAGE_CONFIG`.

      Parameters:
        `swarm` - Swarm instance to configure.
      Throws:
        `MalformedURLException` - If a URL is attempted to be read and fails.
        `IOException`

    - #### apply

          public void apply(Swarm swarm)
                     throws IOException,
                            ModuleLoadException

      Apply properties and configuration from the parsed commandline to a container.
      Parameters:
        `swarm` - The Swarm instance to apply configuration to.
      Throws:
        `IOException` - If an error occurs resolving any URL.
        `ModuleLoadException`

    - #### extraArguments

          public List<String> extraArguments()

      Any un-parsed non-option arguments.
      Returns:
        The list of unparsed arguments.

    - #### extraArgumentsArray

          public String[] extraArgumentsArray()

      Any un-parsed non-option arguments.
      Returns:
        The array of unparsed arguments.

    - #### invalidArguments

          public List<String> invalidArguments()

      Any invalid options seen during parsing.
      Returns:
        The list of invalid arguments.

    - #### hasInvalidArguments

          public boolean hasInvalidArguments()

      Determine if any invalid arguments were seen during the parse.
      Returns:
        `true` if `invalidArguments()` is not empty, otherwise `false`.

    - #### parse

          public static CommandLine parse(String... args)
                                   throws Exception

      Parse an array of arguments using the default options.
      Parameters:
        `args` - The args to parse.
      Returns:
        The parsed `CommandLine`.
      Throws:
        `Exception`

    - #### parse

          public static CommandLine parse(Options options,
                                          String... args)
                                   throws Exception

      Parse an array of arguments using specific options.
      Parameters:
        `options` - The options to use.
        `args` - The args to parse.
      Returns:
        The parsed `CommandLine`.
      Throws:
        `Exception`

Copyright © 2017 JBoss by Red Hat. All rights reserved.