mirror of https://github.com/apache/iotdb
Feat/cli disable history (#13461)
This commit is contained in:
parent
3f4fa64c5a
commit
0cd0c87486
|
@ -35,6 +35,7 @@ import org.apache.commons.cli.Options;
|
|||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.thrift.TException;
|
||||
import org.jline.reader.EndOfFileException;
|
||||
import org.jline.reader.LineReader;
|
||||
import org.jline.reader.UserInterruptException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -96,8 +97,11 @@ public class Cli extends AbstractCli {
|
|||
ctx.getPrinter().println(IOTDB_ERROR_PREFIX + "Exit cli with error " + e.getMessage());
|
||||
ctx.exit(CODE_ERROR);
|
||||
}
|
||||
|
||||
ctx.setLineReader(JlineUtils.getLineReader(ctx, username, host, port));
|
||||
LineReader lineReader = JlineUtils.getLineReader(ctx, username, host, port);
|
||||
if (ctx.isDisableCliHistory()) {
|
||||
lineReader.getVariables().put(LineReader.DISABLE_HISTORY, Boolean.TRUE);
|
||||
}
|
||||
ctx.setLineReader(lineReader);
|
||||
serve(ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,14 +36,26 @@ public class CliContext {
|
|||
|
||||
private final ExitType exitType;
|
||||
|
||||
private final boolean disableCliHistory;
|
||||
|
||||
private LineReader lineReader;
|
||||
|
||||
public CliContext(InputStream in, PrintStream out, PrintStream err, ExitType exitType) {
|
||||
this(in, out, err, exitType, false);
|
||||
}
|
||||
|
||||
public CliContext(
|
||||
InputStream in,
|
||||
PrintStream out,
|
||||
PrintStream err,
|
||||
ExitType exitType,
|
||||
boolean disableCliHistory) {
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
this.err = err;
|
||||
this.exitType = exitType;
|
||||
this.printer = new IoTPrinter(out);
|
||||
this.disableCliHistory = disableCliHistory;
|
||||
}
|
||||
|
||||
public InputStream getIn() {
|
||||
|
@ -66,6 +78,10 @@ public class CliContext {
|
|||
return exitType;
|
||||
}
|
||||
|
||||
public boolean isDisableCliHistory() {
|
||||
return disableCliHistory;
|
||||
}
|
||||
|
||||
public LineReader getLineReader() {
|
||||
return lineReader;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue