summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-05-07 12:04:19 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-05-07 12:04:19 +0200
commit526efec2b1578b145d471ba0b9cee42c4088ce4d (patch)
treea00b8ae1ae647c35e8b01ecb212e884301e7f992
parenteb278af8186496a6517bb1d27b7210bd173841fd (diff)
downloadTwitterDataAnalytics-526efec2b1578b145d471ba0b9cee42c4088ce4d.tar.gz
Add command to repeat last command.
-rw-r--r--src/main/TweetShell.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/TweetShell.java b/src/main/TweetShell.java
index 231007f..354bdf9 100644
--- a/src/main/TweetShell.java
+++ b/src/main/TweetShell.java
@@ -126,15 +126,24 @@ public class TweetShell implements TwitterApi.PinSupplier {
*/
public void process_forever() {
System.err.println("Entering interactive shell, type 'help' for help "
- + "or 'exit' to leave.");
+ + "or 'exit' to leave. '.' repeats the previous interactive "
+ + "command.");
// print prompt for reading first command
printPrompt();
+ String lastLine = "";
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
+ // repeat last command
+ if (line.equals(".")) {
+ line = lastLine;
+ }
if (!execute(line)) {
// requested to terminate
break;
}
+ if (!line.isEmpty()) {
+ lastLine = line;
+ }
// print prompt for reading next line
printPrompt();
}