You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/04/25 15:56:00 UTC

svn commit: r651607 - in /servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main: java/org/apache/geronimo/gshell/commands/builtins/ resources/META-INF/spring/

Author: gnodet
Date: Fri Apr 25 06:55:59 2008
New Revision: 651607

URL: http://svn.apache.org/viewvc?rev=651607&view=rev
Log:
SMX4KNL-30: Create an history command to be able to browse previous commands easily

Added:
    servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryCommand.java
Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml
    servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
    servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell.xml

Added: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryCommand.java?rev=651607&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryCommand.java (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryCommand.java Fri Apr 25 06:55:59 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.commands.builtins;
+
+import java.util.List;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.support.OsgiCommandSupport;
+import org.apache.geronimo.gshell.command.annotation.Requirement;
+import jline.History;
+
+/**
+ * Displays the history of commands
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@CommandComponent(id="gshell-builtins:history", description="Displays the history of commands")
+public class HistoryCommand
+    extends OsgiCommandSupport
+{
+    @Requirement
+    private History history;
+
+    @Option(name="-n", description="Do not print the trailing newline character")
+    private boolean trailingNewline = true;
+
+    @Argument(description="Arguments")
+    private List<String> args;
+
+    public HistoryCommand(History history) {
+        this.history = history;
+    }
+
+    protected OsgiCommandSupport createCommand() throws Exception {
+        return new HistoryCommand(history);
+    }
+
+    protected Object doExecute() throws Exception {
+        for (Object o : history.getHistoryList()) {
+            io.out.println(o);
+        }
+        return SUCCESS;
+    }
+}
\ No newline at end of file

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml?rev=651607&r1=651606&r2=651607&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml Fri Apr 25 06:55:59 2008
@@ -40,6 +40,10 @@
         <constructor-arg ref="branding" />
     </bean>
 
+    <bean id="history-cmd" class="org.apache.geronimo.gshell.commands.builtins.HistoryCommand">
+        <constructor-arg ref="history" />
+    </bean>
+
     <bean id="info" class="org.apache.geronimo.gshell.commands.builtins.InfoCommand">
         <constructor-arg ref="branding" />
     </bean>

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml?rev=651607&r1=651606&r2=651607&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml Fri Apr 25 06:55:59 2008
@@ -54,6 +54,12 @@
       </osgi:service-properties>
     </osgi:service>
 
+    <osgi:service ref="history-cmd" interface="org.apache.geronimo.gshell.command.Command">
+      <osgi:service-properties>
+      	<entry key="alias" value="history"/>
+      </osgi:service-properties>
+    </osgi:service>
+
     <osgi:service ref="info" interface="org.apache.geronimo.gshell.command.Command">
     </osgi:service>
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell.xml?rev=651607&r1=651606&r2=651607&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell.xml Fri Apr 25 06:55:59 2008
@@ -56,6 +56,7 @@
         <constructor-arg ref="terminal" />
         <constructor-arg ref="environment" />
         <constructor-arg ref="io" />
+        <constructor-arg ref="history" />
         <property name="prompter" ref="prompter" />
     </bean>
 
@@ -79,6 +80,10 @@
     </bean>
 
     <bean id="io" class="org.apache.geronimo.gshell.spring.ProxyIO" />
+
+    <bean id="history" class="org.apache.geronimo.gshell.console.FileHistory">
+        <constructor-arg ref="branding" />
+    </bean>
 
     <bean id="prompter" class="org.apache.geronimo.gshell.spring.Prompter">
         <constructor-arg ref="shellInfo" />