From 9f8c8ef3e961bf30d33fc3564567eb830312ee6e Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 23 Jan 2018 15:40:43 -0700 Subject: [PATCH] Parse CLI's `-d` or `--debug` flag as turning on debug (elastic/x-pack-elasticsearch#3686) Previously in order to turn on debug mode for the CLI, a user needed to specify `-d true`. You now only need to specify `-d` or `--debug` to turn on debug mode. Resolves elastic/x-pack-elasticsearch#3315 Original commit: elastic/x-pack-elasticsearch@d5052059e639dc670fa3f61035baf72d81d864bb --- .../main/java/org/elasticsearch/xpack/sql/cli/Cli.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java b/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java index 298a3ecd7bc..edf051cf928 100644 --- a/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java +++ b/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java @@ -32,17 +32,13 @@ import java.util.List; import java.util.logging.LogManager; public class Cli extends LoggingAwareCommand { - private final OptionSpec debugOption; private final OptionSpec keystoreLocation; private final OptionSpec checkOption; private final OptionSpec connectionString; private Cli() { super("Elasticsearch SQL CLI"); - this.debugOption = parser.acceptsAll(Arrays.asList("d", "debug"), - "Enable debug logging") - .withRequiredArg().ofType(Boolean.class) - .defaultsTo(Boolean.parseBoolean(System.getProperty("cli.debug", "false"))); + parser.acceptsAll(Arrays.asList("d", "debug"), "Enable debug logging"); this.keystoreLocation = parser.acceptsAll( Arrays.asList("k", "keystore_location"), "Location of a keystore to use when setting up SSL. " @@ -85,7 +81,7 @@ public class Cli extends LoggingAwareCommand { @Override protected void execute(org.elasticsearch.cli.Terminal terminal, OptionSet options) throws Exception { - boolean debug = debugOption.value(options); + boolean debug = Boolean.parseBoolean(System.getProperty("cli.debug", "false")) || options.has("d") || options.has("debug"); boolean checkConnection = checkOption.value(options); List args = connectionString.values(options); if (args.size() > 1) {