From 3ca00353c86a1b1211da687e59bc69a71ede65aa Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Fri, 22 Sep 2017 10:59:55 -0400 Subject: [PATCH] SQL: Clean up unused calls in CLI (elastic/x-pack-elasticsearch#2593) Original commit: elastic/x-pack-elasticsearch@ba3c64b09cbdc4592e442950fa9e17d4291e49a1 --- sql/cli/build.gradle | 2 -- .../org/elasticsearch/xpack/sql/cli/Cli.java | 19 +---------- .../org/elasticsearch/xpack/sql/cli/Keys.java | 34 ------------------- 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Keys.java diff --git a/sql/cli/build.gradle b/sql/cli/build.gradle index 0c098c3a5b2..372fdbddf8f 100644 --- a/sql/cli/build.gradle +++ b/sql/cli/build.gradle @@ -1,5 +1,3 @@ -import org.elasticsearch.gradle.test.RunTask - apply plugin: 'elasticsearch.build' /* We don't use the 'application' plugin because it builds a zip and tgz which * we don't want. */ diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java index 52e7aca7fe9..89e0fc4fb10 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java @@ -6,10 +6,8 @@ package org.elasticsearch.xpack.sql.cli; import org.elasticsearch.xpack.sql.cli.net.protocol.QueryResponse; -import org.elasticsearch.xpack.sql.net.client.SuppressForbidden; import org.elasticsearch.xpack.sql.net.client.util.IOUtils; import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest; -import org.jline.keymap.BindingReader; import org.jline.reader.EndOfFileException; import org.jline.reader.LineReader; import org.jline.reader.LineReaderBuilder; @@ -54,26 +52,13 @@ public class Cli { } } - @SuppressForbidden(reason = "CLI application") - private static void terminateWithError() { - System.exit(1); - } - private final Terminal term; - private final BindingReader bindingReader; - private final Keys keys; - private final CliConfiguration cfg; private final CliHttpClient cliClient; private int fetchSize = AbstractQueryInitRequest.DEFAULT_FETCH_SIZE; private String fetchSeparator = ""; Cli(CliConfiguration cfg, Terminal terminal) { term = terminal; - // NOCOMMIT figure out if we need to build these for side effects or not. We don't currently use them. - bindingReader = new BindingReader(term.reader()); - keys = new Keys(term); - - this.cfg = cfg; cliClient = new CliHttpClient(cfg); } @@ -85,13 +70,11 @@ public class Cli { .completer(Completers.INSTANCE) .build(); - String prompt = null; - String DEFAULT_PROMPT = new AttributedString("sql> ", DEFAULT.foreground(YELLOW)).toAnsi(term); String MULTI_LINE_PROMPT = new AttributedString(" | ", DEFAULT.foreground(YELLOW)).toAnsi(term); StringBuilder multiLine = new StringBuilder(); - prompt = DEFAULT_PROMPT; + String prompt = DEFAULT_PROMPT; out.flush(); printLogo(); diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Keys.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Keys.java deleted file mode 100644 index 40a1105d6e0..00000000000 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Keys.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli; - -import org.jline.keymap.KeyMap; -import org.jline.terminal.Terminal; -import org.jline.utils.InfoCmp.Capability; - -import static org.jline.keymap.KeyMap.key; - -class Keys { - - enum Key { - UP, - DOWN, - LEFT, - RIGHT, - NONE - } - - final KeyMap keys = new KeyMap<>(); - - Keys(Terminal terminal) { - keys.setNomatch(Key.NONE); - keys.setAmbiguousTimeout(400); - keys.bind(Key.UP, key(terminal, Capability.key_up)); - keys.bind(Key.DOWN, key(terminal, Capability.key_down)); - keys.bind(Key.RIGHT, key(terminal, Capability.key_right)); - keys.bind(Key.LEFT, key(terminal, Capability.key_left)); - } -}