mirror of
https://github.com/apache/sqoop.git
synced 2025-05-06 04:20:56 +08:00
SQOOP-2764: Sqoop2: Sqoop shell history is no longer working
(Dian Fu via Jarek Jarcec Cecho)
This commit is contained in:
parent
8d63df7145
commit
008b126932
@ -22,6 +22,9 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import jline.console.history.History;
|
||||
import jline.console.history.PersistentHistory;
|
||||
|
||||
import org.apache.sqoop.shell.core.Constants;
|
||||
import org.apache.sqoop.shell.utils.ThrowableDisplayer;
|
||||
import org.codehaus.groovy.runtime.MethodClosure;
|
||||
@ -56,8 +59,8 @@ public final class SqoopShell {
|
||||
|
||||
static {
|
||||
commandsToKeep = new HashSet<String>();
|
||||
commandsToKeep.add("exit");
|
||||
commandsToKeep.add("history");
|
||||
commandsToKeep.add(":exit");
|
||||
commandsToKeep.add(":history");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,11 +71,26 @@ public final class SqoopShell {
|
||||
*/
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.setProperty("groovysh.prompt", Constants.SQOOP_PROMPT);
|
||||
Groovysh shell = new Groovysh();
|
||||
final Groovysh shell = new Groovysh();
|
||||
|
||||
// Install our error hook (exception handling)
|
||||
shell.setErrorHook(new MethodClosure(ThrowableDisplayer.class, "errorHook"));
|
||||
|
||||
// Install shutdown hook
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
History history = shell.getRunner().getReader().getHistory();
|
||||
if (history instanceof PersistentHistory) {
|
||||
try {
|
||||
((PersistentHistory)history).flush();
|
||||
} catch (IOException e) {
|
||||
// Ignore this exception as it only affects history
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CommandRegistry registry = shell.getRegistry();
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Command> iterator = registry.iterator();
|
||||
|
Loading…
Reference in New Issue
Block a user