java.lang.Object
org.elasticsearch.cli.Command
org.elasticsearch.common.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. -
Method Summary
Modifier and TypeMethodDescriptionprotected Environment
createEnv
(joptsimple.OptionSet options, ProcessInfo processInfo) Create anEnvironment
for the command to use.protected void
execute
(Terminal terminal, joptsimple.OptionSet options, ProcessInfo processInfo) abstract void
execute
(Terminal terminal, joptsimple.OptionSet options, Environment env, ProcessInfo processInfo) Execute the command with the initializedEnvironment
.protected Build.Type
Methods inherited from class org.elasticsearch.cli.Command
close, exit, main, mainWithoutErrorHandling, parseOptions, 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
-
-
Method Details
-
execute
protected void execute(Terminal terminal, joptsimple.OptionSet options, ProcessInfo processInfo) throws Exception -
createEnv
protected Environment createEnv(joptsimple.OptionSet options, ProcessInfo processInfo) throws UserException Create anEnvironment
for the command to use. Overrideable for tests.- Throws:
UserException
-
getBuildType
-
execute
public abstract void execute(Terminal terminal, joptsimple.OptionSet options, Environment env, ProcessInfo processInfo) throws Exception Execute the command with the initializedEnvironment
.- Throws:
Exception
-