SQL: Clean up unused calls in CLI (elastic/x-pack-elasticsearch#2593)
Original commit: elastic/x-pack-elasticsearch@ba3c64b09c
This commit is contained in:
parent
3b8d8487f2
commit
3ca00353c8
|
@ -1,5 +1,3 @@
|
||||||
import org.elasticsearch.gradle.test.RunTask
|
|
||||||
|
|
||||||
apply plugin: 'elasticsearch.build'
|
apply plugin: 'elasticsearch.build'
|
||||||
/* We don't use the 'application' plugin because it builds a zip and tgz which
|
/* We don't use the 'application' plugin because it builds a zip and tgz which
|
||||||
* we don't want. */
|
* we don't want. */
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
package org.elasticsearch.xpack.sql.cli;
|
package org.elasticsearch.xpack.sql.cli;
|
||||||
|
|
||||||
import org.elasticsearch.xpack.sql.cli.net.protocol.QueryResponse;
|
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.net.client.util.IOUtils;
|
||||||
import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest;
|
import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest;
|
||||||
import org.jline.keymap.BindingReader;
|
|
||||||
import org.jline.reader.EndOfFileException;
|
import org.jline.reader.EndOfFileException;
|
||||||
import org.jline.reader.LineReader;
|
import org.jline.reader.LineReader;
|
||||||
import org.jline.reader.LineReaderBuilder;
|
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 Terminal term;
|
||||||
private final BindingReader bindingReader;
|
|
||||||
private final Keys keys;
|
|
||||||
private final CliConfiguration cfg;
|
|
||||||
private final CliHttpClient cliClient;
|
private final CliHttpClient cliClient;
|
||||||
private int fetchSize = AbstractQueryInitRequest.DEFAULT_FETCH_SIZE;
|
private int fetchSize = AbstractQueryInitRequest.DEFAULT_FETCH_SIZE;
|
||||||
private String fetchSeparator = "";
|
private String fetchSeparator = "";
|
||||||
|
|
||||||
Cli(CliConfiguration cfg, Terminal terminal) {
|
Cli(CliConfiguration cfg, Terminal terminal) {
|
||||||
term = 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);
|
cliClient = new CliHttpClient(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,13 +70,11 @@ public class Cli {
|
||||||
.completer(Completers.INSTANCE)
|
.completer(Completers.INSTANCE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String prompt = null;
|
|
||||||
|
|
||||||
String DEFAULT_PROMPT = new AttributedString("sql> ", DEFAULT.foreground(YELLOW)).toAnsi(term);
|
String DEFAULT_PROMPT = new AttributedString("sql> ", DEFAULT.foreground(YELLOW)).toAnsi(term);
|
||||||
String MULTI_LINE_PROMPT = new AttributedString(" | ", DEFAULT.foreground(YELLOW)).toAnsi(term);
|
String MULTI_LINE_PROMPT = new AttributedString(" | ", DEFAULT.foreground(YELLOW)).toAnsi(term);
|
||||||
|
|
||||||
StringBuilder multiLine = new StringBuilder();
|
StringBuilder multiLine = new StringBuilder();
|
||||||
prompt = DEFAULT_PROMPT;
|
String prompt = DEFAULT_PROMPT;
|
||||||
|
|
||||||
out.flush();
|
out.flush();
|
||||||
printLogo();
|
printLogo();
|
||||||
|
|
|
@ -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<Key> 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));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue