Package org.elasticsearch.cli
Class EnvironmentAwareCommand
org.elasticsearch.cli.Command
org.elasticsearch.cli.EnvironmentAwareCommand
- All Implemented Interfaces:
,
- 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.-
Field Summary
Fields inherited from class org.elasticsearch.cli.Command
description, parser
-
Constructor Summary
ConstructorDescriptiondescription)
Construct the command with the specified command description.description, beforeMain)
Construct the command with the specified command description and runnable to execute before main is invoked. -
Method Summary
Modifier and TypeMethodDescriptionprotected Environment
<,> settings)
Create anEnvironment
for the command to use.protected Environment
Create anEnvironment
for the command to use.protected void
execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options)
protected abstract void
execute(org.elasticsearch.cli.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
Methods inherited from class java.lang.
, , , , , , , , , ,
-
Constructor Details
-
EnvironmentAwareCommand
public EnvironmentAwareCommand( 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( description, 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 descriptionbeforeMain
- the before-main runnable
-
-
Method Details
-
execute
protected void execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options) throws- Specified by:
execute
in classorg.elasticsearch.cli.Command
- Throws:
-
createEnv
protected <,> settings) throws org.elasticsearch.cli.UserExceptionCreate anEnvironment
for the command to use. Overrideable for tests.- Throws:
org.elasticsearch.cli.UserException
-
createEnv
protected final Environment createEnv(Settings baseSettings, <,> settings) throws org.elasticsearch.cli.UserExceptionCreate anEnvironment
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) throwsExecute the command with the initializedEnvironment
.- Throws:
-