From 526efec2b1578b145d471ba0b9cee42c4088ce4d Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 7 May 2014 12:04:19 +0200 Subject: Add command to repeat last command. --- src/main/TweetShell.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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(); } -- cgit v1.2.1