Package org.elasticsearch.cli
Class EnvironmentAwareCommand
java.lang.Object
org.elasticsearch.cli.Command
org.elasticsearch.cli.EnvironmentAwareCommand
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
ElasticsearchNodeCommand,KeyStoreAwareCommand
A cli command which requires an
Environment to use current paths and settings.-
Field Summary
Fields inherited from class org.elasticsearch.cli.Command
description, parser -
Constructor Summary
ConstructorsConstructorDescriptionEnvironmentAwareCommand(String description) Construct the command with the specified command description.EnvironmentAwareCommand(String description, Runnable beforeMain) Construct the command with the specified command description and runnable to execute before main is invoked. -
Method Summary
Modifier and TypeMethodDescriptionprotected EnvironmentCreate anEnvironmentfor the command to use.protected final EnvironmentCreate anEnvironmentfor the command to use.protected voidprotected abstract voidexecute(Terminal terminal, joptsimple.OptionSet options, Environment env) Execute the command with the initializedEnvironment.Methods inherited from class org.elasticsearch.cli.Command
addShutdownHook, close, exit, main, printAdditionalHelp, printUserException
-
Constructor Details
-
EnvironmentAwareCommand
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
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 descriptionbeforeMain- the before-main runnable
-
-
Method Details
-
execute
-
createEnv
Create anEnvironmentfor the command to use. Overrideable for tests.- Throws:
UserException
-
createEnv
protected final Environment createEnv(Settings baseSettings, Map<String, String> settings) throws UserExceptionCreate anEnvironmentfor the command to use. Overrideable for tests.- Throws:
UserException
-
execute
protected abstract void execute(Terminal terminal, joptsimple.OptionSet options, Environment env) throws Exception Execute the command with the initializedEnvironment.- Throws:
Exception
-