You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ja...@apache.org on 2013/10/30 19:52:02 UTC
svn commit: r1537241 -
/karaf/branches/karaf-2.3.x/shell/commands/src/main/java/org/apache/karaf/shell/commands/HistoryAction.java
Author: janstey
Date: Wed Oct 30 18:52:02 2013
New Revision: 1537241
URL: http://svn.apache.org/r1537241
Log:
KARAF-2539 - Add --clear option to history command
Modified:
karaf/branches/karaf-2.3.x/shell/commands/src/main/java/org/apache/karaf/shell/commands/HistoryAction.java
Modified: karaf/branches/karaf-2.3.x/shell/commands/src/main/java/org/apache/karaf/shell/commands/HistoryAction.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/commands/src/main/java/org/apache/karaf/shell/commands/HistoryAction.java?rev=1537241&r1=1537240&r2=1537241&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/commands/src/main/java/org/apache/karaf/shell/commands/HistoryAction.java (original)
+++ karaf/branches/karaf-2.3.x/shell/commands/src/main/java/org/apache/karaf/shell/commands/HistoryAction.java Wed Oct 30 18:52:02 2013
@@ -18,6 +18,7 @@ package org.apache.karaf.shell.commands;
import jline.console.history.History;
import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
import org.apache.karaf.shell.console.AbstractAction;
import org.fusesource.jansi.Ansi;
@@ -27,9 +28,16 @@ import org.fusesource.jansi.Ansi;
@Command(scope = "shell", name="history", description="Prints command history.")
public class HistoryAction extends AbstractAction {
- @Override
- protected Object doExecute() throws Exception {
- History history = (History) session.get(".jline.history");
+ @Option(name = "-c", aliases = { "--clear" }, description = "Clears the shell command history.", required = false, multiValued = false)
+ private boolean clear;
+
+ @Override
+ protected Object doExecute() throws Exception {
+ History history = (History) session.get(".jline.history");
+
+ if (history != null && clear) {
+ history.clear();
+ }
for (History.Entry element : history) {
System.out.println(