Package io.vertx.core.spi.launcher

## Class DefaultCommand

- java.lang.Object
- - io.vertx.core.spi.launcher.DefaultCommand

- All Implemented Interfaces:
    `Command`

      public abstract class DefaultCommand
      extends Object
      implements Command

  Default implementation of `Command` using annotation to define itself. It is highly recommended to extend this class when implementing a command.

  It defines two hidden `Option`s to create system properties (`-Dkey=value`) and a way to configure the current working directory.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected ExecutionContext` | `executionContext` | The execution context of the command.
    `protected PrintStream` | `out` | The `PrintStream` that the command can use to write on the console.
    `protected List<String>` | `systemProperties` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultCommand()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `applySystemProperties()` | Sets the system properties specified by the user command line.
    `File` | `getCwd()` |
    `PrintStream` | `out()` |
    `void` | `setCwd​(File cwd)` | Sets the current working directory.
    `void` | `setSystemProps​(List<String> props)` | Gets system properties passed in the user command line.
    `void` | `setUp​(ExecutionContext ec)` | Set up the command execution environment.
    `void` | `tearDown()` | The command has been executed.

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

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

    - ### Methods inherited from interface io.vertx.core.spi.launcher.Command

      `run`

- - ### Field Detail

    - #### systemProperties

          protected List<String> systemProperties

    - #### executionContext

          protected ExecutionContext executionContext

      The execution context of the command.

    - #### out

          protected PrintStream out

      The `PrintStream` that the command can use to write on the console.

  - ### Constructor Detail

    - #### DefaultCommand

          public DefaultCommand()

  - ### Method Detail

    - #### getCwd

          public File getCwd()

      Returns:
        the configure current working directory. If not set use the "regular" Java current working directory.

    - #### setCwd

          public void setCwd​(File cwd)

      Sets the current working directory. This method is called when the user configure the "cwd" option as follows: `--cwd=the-directory`.
      Parameters:
        `cwd` - the directory

    - #### setSystemProps

          public void setSystemProps​(List<String> props)

      Gets system properties passed in the user command line. The user can configure system properties using `-Dkey=value`.
      Parameters:
        `props` - the properties

    - #### setUp

          public void setUp​(ExecutionContext ec)
                     throws CLIException

      Description copied from interface: `Command`
      Set up the command execution environment. The command line model has been retrieved and is frozen. Values has been set / injected. You can use this callback to validate the inputs.
      Specified by:
        `setUp` in interface `Command`
      Parameters:
        `ec` - the context
      Throws:
        `CLIException` - if the validation failed

    - #### out

          public PrintStream out()

      Returns:
        the print stream on which message should be written.

    - #### tearDown

          public void tearDown()
                        throws CLIException

      Description copied from interface: `Command`
      The command has been executed. Use this method to cleanup the environment.
      Specified by:
        `tearDown` in interface `Command`
      Throws:
        `CLIException` - if anything went wrong

    - #### applySystemProperties

          protected void applySystemProperties()

      Sets the system properties specified by the user command line.