Class EnvironmentAwareCommand

java.lang.Object
org.elasticsearch.cli.Command
org.elasticsearch.cli.EnvironmentAwareCommand
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
ElasticsearchNodeCommand, KeyStoreAwareCommand

public abstract class EnvironmentAwareCommand extends org.elasticsearch.cli.Command
A cli command which requires an Environment to use current paths and settings.
  • Constructor Details

    • EnvironmentAwareCommand

      public EnvironmentAwareCommand(String description)
      Construct the command with the specified command description. This command will have logging configured without reading Elasticsearch configuration files.
      Parameters:
      description - the command description
    • EnvironmentAwareCommand

      public EnvironmentAwareCommand(String description, Runnable beforeMain)
      Construct the command with the specified command description and runnable to execute before main is invoked. Commands constructed with this constructor must take ownership of configuring logging.
      Parameters:
      description - the command description
      beforeMain - the before-main runnable
  • Method Details

    • execute

      protected void execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options) throws Exception
      Specified by:
      execute in class org.elasticsearch.cli.Command
      Throws:
      Exception
    • createEnv

      protected Environment createEnv(Map<String,String> settings) throws org.elasticsearch.cli.UserException
      Create an Environment for the command to use. Overrideable for tests.
      Throws:
      org.elasticsearch.cli.UserException
    • createEnv

      protected final Environment createEnv(Settings baseSettings, Map<String,String> settings) throws org.elasticsearch.cli.UserException
      Create an Environment for the command to use. Overrideable for tests.
      Throws:
      org.elasticsearch.cli.UserException
    • execute

      protected abstract void execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options, Environment env) throws Exception
      Execute the command with the initialized Environment.
      Throws:
      Exception