You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/11/28 12:25:43 UTC

svn commit: r721437 [1/2] - in /geronimo/gshell/trunk: ./ gshell-assembly/src/main/underlay/etc/ gshell-commands/ gshell-commands/gshell-netutils/ gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/ gshell-comman...

Author: jdillon
Date: Fri Nov 28 03:25:42 2008
New Revision: 721437

URL: http://svn.apache.org/viewvc?rev=721437&view=rev
Log:
Split up gshell-opitional into linux/rpm-like packages/plugins

Added:
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/   (props changed)
      - copied from r721400, geronimo/gshell/trunk/gshell-commands/gshell-optional/
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/   (props changed)
      - copied from r721400, geronimo/gshell/trunk/gshell-commands/gshell-optional/
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/   (props changed)
      - copied from r721400, geronimo/gshell/trunk/gshell-commands/gshell-optional/
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/PrintfAction.java   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/resources/org/apache/geronimo/gshell/commands/textutils/
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/resources/org/apache/geronimo/gshell/commands/textutils/CatAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/resources/org/apache/geronimo/gshell/commands/textutils/GrepAction.properties   (with props)
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/resources/org/apache/geronimo/gshell/commands/textutils/PrintfAction.properties   (with props)
Removed:
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/optional/
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/optional/
    geronimo/gshell/trunk/gshell-commands/gshell-optional/
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/optional/
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/optional/
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/optional/
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/resources/org/apache/geronimo/gshell/commands/optional/
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/pom.xml
    geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/META-INF/gshell/components.xml
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/pom.xml
    geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/META-INF/gshell/components.xml
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/pom.xml
    geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/resources/META-INF/gshell/components.xml
    geronimo/gshell/trunk/gshell-commands/pom.xml
    geronimo/gshell/trunk/pom.xml

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml?rev=721437&r1=721436&r2=721437&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml Fri Nov 28 03:25:42 2008
@@ -83,19 +83,32 @@
 
                 <bean class="org.apache.geronimo.gshell.artifact.Artifact">
                     <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="name" value="gshell-shellutils"/>
+                    <property name="version" value="${gshell.version}"/>
+                </bean>
+
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
                     <property name="name" value="gshell-fileutils"/>
                     <property name="version" value="${gshell.version}"/>
                 </bean>
 
                 <bean class="org.apache.geronimo.gshell.artifact.Artifact">
                     <property name="group" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="name" value="gshell-admin"/>
+                    <property name="name" value="gshell-textutils"/>
                     <property name="version" value="${gshell.version}"/>
                 </bean>
 
                 <bean class="org.apache.geronimo.gshell.artifact.Artifact">
                     <property name="group" value="org.apache.geronimo.gshell.commands"/>
-                    <property name="name" value="gshell-optional"/>
+                    <property name="name" value="gshell-netutils"/>
+                    <property name="version" value="${gshell.version}"/>
+                </bean>
+
+
+                <bean class="org.apache.geronimo.gshell.artifact.Artifact">
+                    <property name="group" value="org.apache.geronimo.gshell.commands"/>
+                    <property name="name" value="gshell-admin"/>
                     <property name="version" value="${gshell.version}"/>
                 </bean>
 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 28 03:25:42 2008
@@ -0,0 +1 @@
+target-eclipse

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-netutils/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-netutils/pom.xml?rev=721437&r1=721400&r2=721437&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-netutils/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-netutils/pom.xml Fri Nov 28 03:25:42 2008
@@ -30,11 +30,11 @@
         <version>1.0-alpha-2-SNAPSHOT</version>
     </parent>
     
-    <artifactId>gshell-optional</artifactId>
-    <name>GShell Commands :: Optional</name>
+    <artifactId>gshell-netutils</artifactId>
+    <name>GShell Commands :: Network Utilities</name>
     
     <description>
-        Provides some optional commands.
+        Network utilities.
     </description>
 
     <dependencies>
@@ -43,5 +43,5 @@
             <artifactId>gshell-vfs</artifactId>
         </dependency>
     </dependencies>
-    
+
 </project>
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.netutils;
+
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+
+import java.net.InetAddress;
+
+/**
+ * Displays the name of the current host.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HostnameAction
+    implements CommandAction
+{
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        InetAddress localhost = InetAddress.getLocalHost();
+        io.info(localhost.getHostName());
+        io.verbose(localhost.getHostAddress());
+
+        return Result.SUCCESS;
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/java/org/apache/geronimo/gshell/commands/netutils/HostnameAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/META-INF/gshell/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/META-INF/gshell/components.xml?rev=721437&r1=721400&r2=721437&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/META-INF/gshell/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/META-INF/gshell/components.xml Fri Nov 28 03:25:42 2008
@@ -31,62 +31,10 @@
        default-init-method="init"
        default-destroy-method="destroy">
 
-    <bean id="vfsCommandActionTemplate" abstract="true">
-        <property name="fileSystemAccess" ref="fileSystemAccess"/>
-    </bean>
-    
-    <gshell:plugin name="gshell-optional">
+    <gshell:plugin name="gshell-netutils">
         <gshell:command-bundle name="default">
-            <gshell:command name="printf">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.PrintfAction"/>
-            </gshell:command>
-            
-            <gshell:command name="exec">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.ExecuteAction"/>
-            </gshell:command>
-
-            <gshell:command name="java">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.JavaAction"/>
-            </gshell:command>
-
-            <gshell:command name="sleep">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.SleepAction"/>
-            </gshell:command>
-
-            <gshell:command name="date">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.DateAction"/>
-            </gshell:command>
-
             <gshell:command name="hostname">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.HostnameAction"/>
-            </gshell:command>
-
-            <gshell:command name="cat">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.CatAction" parent="vfsCommandActionTemplate"/>
-                <gshell:completers>
-                    <ref bean="fileObjectNameCompleter"/>
-                    <null/>
-                </gshell:completers>
-            </gshell:command>
-
-            <gshell:command name="edit">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.EditAction" parent="vfsCommandActionTemplate"/>
-                <gshell:completers>
-                    <ref bean="fileObjectNameCompleter"/>
-                    <null/>
-                </gshell:completers>
-            </gshell:command>
-
-            <gshell:command name="find">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.FindAction" parent="vfsCommandActionTemplate"/>
-                <gshell:completers>
-                    <ref bean="fileObjectNameCompleter"/>
-                    <null/>
-                </gshell:completers>
-            </gshell:command>
-
-            <gshell:command name="grep">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.GrepAction" parent="vfsCommandActionTemplate"/>
+                <gshell:action class="org.apache.geronimo.gshell.commands.netutils.HostnameAction"/>
             </gshell:command>
         </gshell:command-bundle>
     </gshell:plugin>

Added: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,27 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Displays the name of the current host.
+
+command.manual=\
+  TODO: hostname manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-netutils/src/main/resources/org/apache/geronimo/gshell/commands/netutils/HostnameAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 28 03:25:42 2008
@@ -0,0 +1 @@
+target-eclipse

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/pom.xml?rev=721437&r1=721400&r2=721437&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/pom.xml Fri Nov 28 03:25:42 2008
@@ -30,11 +30,11 @@
         <version>1.0-alpha-2-SNAPSHOT</version>
     </parent>
     
-    <artifactId>gshell-optional</artifactId>
-    <name>GShell Commands :: Optional</name>
+    <artifactId>gshell-shellutils</artifactId>
+    <name>GShell Commands :: Shell Utilities</name>
     
     <description>
-        Provides some optional commands.
+        Shell Utilities.
     </description>
 
     <dependencies>
@@ -43,5 +43,5 @@
             <artifactId>gshell-vfs</artifactId>
         </dependency>
     </dependencies>
-    
+
 </project>
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.shellutils;
+
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+/**
+ * Displays the current time and date.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DateAction
+    implements CommandAction
+{
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        io.info(DateFormat.getInstance().format(new Date()));
+
+        return Result.SUCCESS;
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/DateAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,148 @@
+/*
+ * 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.shellutils;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.util.Os;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.vfs.FileObjects;
+import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Edit a file with an external editor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EditAction
+    extends VfsActionSupport
+{
+    @Option(name="-e", aliases={"--editor"})
+    private String editor;
+    
+    @Argument(required=true)
+    private String path;
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+
+        FileObject file = resolveFile(context, path);
+
+        ensureFileExists(file);
+        ensureFileHasContent(file);
+        ensureFileIsReadable(file);
+        ensureFileIsWritable(file);
+ 
+        FileObject tmp = file;
+
+        // If the file is not on the local file system, then create tmp file for editing
+        if (!getFileSystemAccess().isLocalFile(file)) {
+            // Create a new temporary file, copy the contents for editing
+            tmp = resolveFile(context, "tmp:/gshell-edit-" + System.currentTimeMillis() + ".txt");
+            log.debug("Using temporary file: {} ({})", tmp, tmp.getClass());
+            tmp.createFile();
+            tmp.copyFrom(file, Selectors.SELECT_SELF);
+        }
+
+        // Have to dereference the VFS file into a local file so the editor can access it
+        File localFile = getFileSystemAccess().getLocalFile(tmp);
+        Object result = edit(context, localFile);
+
+        // If we had to use a tmp file for editing, then copy back and clean up
+        if (tmp != file) {
+            log.debug("Updating original file with edited content");
+            file.copyFrom(tmp, Selectors.SELECT_SELF);
+            tmp.delete();
+            FileObjects.close(tmp);
+        }
+
+        FileObjects.close(file);
+        
+        return result;
+    }
+
+    private Object edit(final CommandContext context, final File localFile) throws Exception {
+        assert context != null;
+        assert localFile != null;
+
+        log.debug("Editing file: {}", localFile);
+
+        List<String> editorCmd = selectEditor();
+
+        log.debug("Executing: {} {}", editorCmd, localFile);
+
+        ProcessBuilder builder = new ProcessBuilder();
+        for (String s : editorCmd) {
+            builder.command().add(s);
+        }
+        builder.command().add(localFile.getAbsolutePath());
+
+        Process p = builder.start();
+
+        log.debug("Waiting for process to exit...");
+        int status = p.waitFor();
+        log.info("Process exited w/status: {}", status);
+
+        return status;
+    }
+
+    private List<String> selectEditor() {
+        String cmd;
+
+        if (editor != null) {
+            cmd = editor;
+        }
+        else {
+            // TODO: Expose a configurable preference for this
+            cmd = getDefaultEditor();
+        }
+
+        // The editor configuration may need to set arguments or whatever, so we have to return a list
+        return Arrays.asList(cmd.split("\\s"));
+    }
+
+    private String getDefaultEditor() {
+        if (Os.isFamily(Os.OS_FAMILY_WINDOWS)) {
+            return "NOTEPAD";    
+        }
+        else if (Os.isFamily(Os.OS_FAMILY_UNIX)) {
+            if (System.getenv("DISPLAY") != null) {
+                String tmp = System.getenv("XEDITOR");
+                if (tmp != null) {
+                    return tmp;
+                }
+            }
+
+            String tmp = System.getenv("EDITOR");
+            if (tmp != null) {
+                return tmp;
+            }
+
+        }
+
+        throw new RuntimeException("Unable to determine the default editor command");
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/EditAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,71 @@
+/*
+ * 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.shellutils;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.io.PumpStreamHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Execute system processes.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExecuteAction
+    implements CommandAction
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Argument(required=true)
+    private List<String> args;
+
+    // TODO: Support setting the process directory and envrionment muck
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        ProcessBuilder builder = new ProcessBuilder(args);
+
+        log.info("Executing: {}", builder.command());
+
+        Process p = builder.start();
+
+        PumpStreamHandler handler = new PumpStreamHandler(io.inputStream, io.outputStream, io.errorStream);
+        handler.attach(p);
+        handler.start();
+
+        log.debug("Waiting for process to exit...");
+
+        int status = p.waitFor();
+        
+        log.info("Process exited w/status: {}", status);
+
+        handler.stop();
+
+        return status;
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,202 @@
+/*
+ * 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.shellutils;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSelectInfo;
+import org.apache.commons.vfs.FileSelector;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
+import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
+import org.apache.geronimo.gshell.vfs.selector.AggregateFileSelector;
+import org.apache.oro.text.GlobCompiler;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternCompiler;
+import org.apache.oro.text.regex.PatternMatcher;
+import org.apache.oro.text.regex.Perl5Matcher;
+
+/**
+ * Find files in a hierarchy.
+ *
+ * @version $Rev$ $Date$
+ */
+public class FindAction
+    extends VfsActionSupport
+{
+    private final AggregateFileSelector selector = new AggregateFileSelector();
+
+    @Option(name="-name")
+    private void addNameFilter(final String name) throws MalformedPatternException {
+        log.debug("Adding -name selector for: {}", name);
+        selector.getSelectors().add(new NameSelector(name));
+    }
+
+    @Option(name="-iname")
+    private void addiNameFilter(final String name) throws MalformedPatternException {
+        log.debug("Adding -iname selector for: {}", name);
+        selector.getSelectors().add(new NameSelector(name, true));
+    }
+
+    @Option(name="-type")
+    private void addTypeFilter(final Type type) {
+        log.debug("Adding -type selector for: {}", type);
+        selector.getSelectors().add(new TypeSelector(type));
+    }
+
+    @Argument(required=true)
+    private String path;
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        FileObject root = resolveFile(context, path);
+
+        ensureFileExists(root);
+
+        find(context, root, selector);
+
+        FileObjects.close(root);
+        
+        return CommandAction.Result.SUCCESS;
+    }
+
+    private void find(final CommandContext context, final FileObject file, final FileSelector selector) throws FileSystemException {
+        assert context != null;
+        assert file != null;
+        assert selector != null;
+
+        FileObject[] files = file.findFiles(selector);
+
+        if (files != null && files.length != 0) {
+            for (FileObject child : files) {
+                display(context, child);
+
+                if (child.getType().hasChildren()) {
+                    find(context, child, selector);
+                }
+            }
+        }
+    }
+
+    private void display(final CommandContext context, final FileObject file) throws FileSystemException {
+        assert context != null;
+        assert file != null;
+
+        IO io = context.getIo();
+        io.info(file.getName().getPath());
+    }
+
+    //
+    // Type & TypeSelector
+    //
+
+    private enum Type
+    {
+        F, // normal file
+        D, // directory
+    }
+
+    private class TypeSelector
+        implements FileSelector
+    {
+        private final Type type;
+
+        public TypeSelector(final Type type) {
+            assert type != null;
+            
+            this.type = type;
+
+            log.trace("Type: {}", type);
+        }
+
+        public boolean includeFile(final FileSelectInfo selection) throws Exception {
+            assert selection != null;
+
+            FileType ftype = selection.getFile().getType();
+
+            switch (type) {
+                case D:
+                    return ftype == FileType.FOLDER;
+
+                case F:
+                    return ftype == FileType.FILE;
+
+                // TODO: Handle FileType.FILE_OR_FOLDER
+
+                default:
+                    return false;
+            }
+        }
+
+        public boolean traverseDescendents(final FileSelectInfo selection) throws Exception {
+            return true;
+        }
+    }
+
+    //
+    // NameSelector
+    //
+    
+    private class NameSelector
+        implements FileSelector
+    {
+        private final Pattern pattern;
+
+        private final PatternMatcher matcher;
+
+        public NameSelector(final String name, final boolean ignoreCase) throws MalformedPatternException {
+            assert name != null;
+
+            PatternCompiler compiler = new GlobCompiler();
+            int options;
+            if (ignoreCase) {
+                options = GlobCompiler.CASE_INSENSITIVE_MASK;
+            }
+            else {
+                options = GlobCompiler.DEFAULT_MASK;
+            }
+            this.pattern = compiler.compile(name, options);
+            this.matcher = new Perl5Matcher();
+
+            log.trace("Pattern: {}", pattern.getPattern());
+        }
+
+        public NameSelector(final String name) throws MalformedPatternException {
+            this(name, false);    
+        }
+
+        public boolean includeFile(final FileSelectInfo selection) throws Exception {
+            assert selection != null;
+            return matcher.matches(selection.getFile().getName().getBaseName(), pattern);
+        }
+
+        public boolean traverseDescendents(final FileSelectInfo selection) throws Exception {
+            return true;
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/FindAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.shellutils;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.Arguments;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * Execute a Java standard application.
+ *
+ * <p>By default looks for static main(String[]) to execute, but
+ * you can specify a different static method that takes a String[]
+ * to execute instead.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaAction
+    implements CommandAction
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Option(name="-m", aliases={"--method"})
+    private String methodName = "main";
+
+    @Argument(index=0, required=true)
+    private String className;
+
+    @Argument(index=1)
+    private List<String> args;
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+
+        log.debug("Loading class: {}", className);
+        Class type = Thread.currentThread().getContextClassLoader().loadClass(className);
+        log.info("Using type: {}", type);
+
+        log.debug("Locating method: {}", methodName);
+        Method method = type.getMethod(methodName, String[].class);
+        log.info("Using method: {}", method);
+
+        log.info("Invoking w/arguments: {}", Arguments.asString(args));
+        Object result = method.invoke(null, args);
+        log.info("Result: {}", result);
+        
+        return result;
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/JavaAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.shellutils;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Sleep... zzzZ
+ *
+ * @version $Rev$ $Date$
+ */
+public class SleepAction
+    implements CommandAction
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
+    @Argument(required=true)
+    private int time = -1;
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+
+        log.info("Sleeping for {}", time);
+
+        try {
+            Thread.sleep(time);
+        }
+        catch (InterruptedException ignore) {
+            log.debug("Sleep was interrupted... :-(");
+        }
+
+        log.info("Awake now");
+
+        return Result.SUCCESS;
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/java/org/apache/geronimo/gshell/commands/shellutils/SleepAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/META-INF/gshell/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/META-INF/gshell/components.xml?rev=721437&r1=721400&r2=721437&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/META-INF/gshell/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/META-INF/gshell/components.xml Fri Nov 28 03:25:42 2008
@@ -35,42 +35,26 @@
         <property name="fileSystemAccess" ref="fileSystemAccess"/>
     </bean>
     
-    <gshell:plugin name="gshell-optional">
+    <gshell:plugin name="gshell-shellutils">
         <gshell:command-bundle name="default">
-            <gshell:command name="printf">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.PrintfAction"/>
-            </gshell:command>
-            
             <gshell:command name="exec">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.ExecuteAction"/>
+                <gshell:action class="org.apache.geronimo.gshell.commands.shellutils.ExecuteAction"/>
             </gshell:command>
 
             <gshell:command name="java">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.JavaAction"/>
+                <gshell:action class="org.apache.geronimo.gshell.commands.shellutils.JavaAction"/>
             </gshell:command>
 
             <gshell:command name="sleep">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.SleepAction"/>
+                <gshell:action class="org.apache.geronimo.gshell.commands.shellutils.SleepAction"/>
             </gshell:command>
 
             <gshell:command name="date">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.DateAction"/>
-            </gshell:command>
-
-            <gshell:command name="hostname">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.HostnameAction"/>
-            </gshell:command>
-
-            <gshell:command name="cat">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.CatAction" parent="vfsCommandActionTemplate"/>
-                <gshell:completers>
-                    <ref bean="fileObjectNameCompleter"/>
-                    <null/>
-                </gshell:completers>
+                <gshell:action class="org.apache.geronimo.gshell.commands.shellutils.DateAction"/>
             </gshell:command>
 
             <gshell:command name="edit">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.EditAction" parent="vfsCommandActionTemplate"/>
+                <gshell:action class="org.apache.geronimo.gshell.commands.shellutils.EditAction" parent="vfsCommandActionTemplate"/>
                 <gshell:completers>
                     <ref bean="fileObjectNameCompleter"/>
                     <null/>
@@ -78,16 +62,12 @@
             </gshell:command>
 
             <gshell:command name="find">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.FindAction" parent="vfsCommandActionTemplate"/>
+                <gshell:action class="org.apache.geronimo.gshell.commands.shellutils.FindAction" parent="vfsCommandActionTemplate"/>
                 <gshell:completers>
                     <ref bean="fileObjectNameCompleter"/>
                     <null/>
                 </gshell:completers>
             </gshell:command>
-
-            <gshell:command name="grep">
-                <gshell:action class="org.apache.geronimo.gshell.commands.optional.GrepAction" parent="vfsCommandActionTemplate"/>
-            </gshell:command>
         </gshell:command-bundle>
     </gshell:plugin>
 

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,27 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Displays the current time and date.
+
+command.manual=\
+  TODO: date manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/DateAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,33 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Edit a file with an external editor.
+
+command.option.editor=Path to external editor command
+command.option.editor.token=CMD
+
+command.argument.path=Path to file to edit
+command.argument.path.token=PATH
+
+command.manual=\
+  TODO: edit manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/EditAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,30 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Execute system processes.
+
+command.argument.args=Process arguments
+command.argument.args.token=ARGUMENTS
+
+command.manual=\
+  TODO: exec manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/ExecuteAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,38 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Find files in a hierarchy.
+
+command.option.addNameFilter=Include files with names matching GLOB
+command.option.addNameFilter.token=GLOB
+
+command.option.addInameFilter=Like -name, but the match is case insensitive
+command.option.addInameFilter.token=GLOB
+
+command.option.addTypeFilter=Include files matching a type
+
+command.argument.path=Path of file to root search under 
+command.argument.path.token=PATH
+
+command.manual=\
+  TODO: find manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/FindAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,36 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Execute a Java standard application.
+
+command.option.methodName=Invoke a named method
+command.option.methodName.token=METHOD
+
+command.argument.className=The name of the class to invoke
+command.argument.className.token=CLASSNAME
+
+command.argument.args=Arguments to pass to the METHOD of CLASSNAME
+command.argument.args.token=ARGS
+
+command.manual=\
+  TODO: java manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/JavaAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties Fri Nov 28 03:25:42 2008
@@ -0,0 +1,30 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Sleep for a bit then wake up.
+
+command.argument.time=Time in milliseconds
+command.argument.time.token=MS
+
+command.manual=\
+  TODO: sleep manual
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-shellutils/src/main/resources/org/apache/geronimo/gshell/commands/shellutils/SleepAction.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 28 03:25:42 2008
@@ -0,0 +1 @@
+target-eclipse

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-textutils/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-textutils/pom.xml?rev=721437&r1=721400&r2=721437&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-textutils/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-textutils/pom.xml Fri Nov 28 03:25:42 2008
@@ -30,11 +30,11 @@
         <version>1.0-alpha-2-SNAPSHOT</version>
     </parent>
     
-    <artifactId>gshell-optional</artifactId>
-    <name>GShell Commands :: Optional</name>
+    <artifactId>gshell-textutils</artifactId>
+    <name>GShell Commands :: Text Utilities</name>
     
     <description>
-        Provides some optional commands.
+        Text Utilities.
     </description>
 
     <dependencies>
@@ -43,5 +43,5 @@
             <artifactId>gshell-vfs</artifactId>
         </dependency>
     </dependencies>
-    
+
 </project>
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.textutils;
+
+import org.apache.commons.vfs.FileContent;
+import org.apache.commons.vfs.FileContentInfo;
+import org.apache.commons.vfs.FileObject;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.io.Closer;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
+import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * Displays the contents of a file.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CatAction
+    extends VfsActionSupport
+{
+    @Option(name="-n")
+    private boolean displayLineNumbers;
+
+    @Argument(required=true)
+    private String path;
+    
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        //
+        // TODO: Support multi-path cat, and the special '-' token (which is the default if no paths are given)
+        //
+
+        FileObject file = resolveFile(context, path);
+
+        ensureFileExists(file);
+        ensureFileHasContent(file);
+
+        FileContent content = file.getContent();
+        FileContentInfo info = content.getContentInfo();
+        log.debug("Content type: {}", info.getContentType());
+        log.debug("Content encoding: {}", info.getContentEncoding());
+
+        //
+        // TODO: Only cat files which we think are text, or warn if its not, allow flag to force
+        //
+
+        log.debug("Displaying file: {}", file.getName());
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(content.getInputStream()));
+        try {
+            cat(reader, io);
+        }
+        finally {
+            Closer.close(reader);
+        }
+
+        FileObjects.close(file);
+        
+        return CommandAction.Result.SUCCESS;
+    }
+
+    private void cat(final BufferedReader reader, final IO io) throws IOException {
+        String line;
+        int lineno = 1;
+
+        while ((line = reader.readLine()) != null) {
+            if (displayLineNumbers) {
+                io.out.print(String.format("%6d  ", lineno++));
+            }
+            io.out.println(line);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/CatAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,230 @@
+/*
+ * 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.textutils;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.io.Closer;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
+import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
+import org.apache.oro.text.MatchAction;
+import org.apache.oro.text.MatchActionInfo;
+import org.apache.oro.text.MatchActionProcessor;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternCompiler;
+import org.apache.oro.text.regex.PatternMatcher;
+import org.apache.oro.text.regex.PatternMatcherInput;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
+
+import java.io.BufferedInputStream;
+
+/**
+ * Displays lines matching a pattern.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GrepAction
+    extends VfsActionSupport
+{
+    /** Return value when matches are found. */
+    public static final int FOUND = 0;
+
+    /** Return value when no matches are found. */
+    public static final int NOT_FOUND = 1;
+
+    //
+    // TODO: Add --pattern option (in addition to this argument) to allow patterns to start with "-"
+    //
+
+    @Argument(index=0, required=true)
+    private String pattern;
+
+    @Argument(index=1, required=false)
+    private String path;
+
+    @Option(name="-c", aliases={"--count"})
+    private boolean count;
+
+    @Option(name="-i", aliases={"--ignore-case"})
+    private boolean ignoreCase;
+
+    @Option(name="-n", aliases={"--line-number"})
+    private boolean lineNumbers;
+
+    @Option(name="-v", aliases={"--invert-match"})
+    private boolean invertMatch;
+
+    /** Tracks the number of matches. */
+    private int matches = 0;
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        final IO io = context.getIo();
+
+        PatternCompiler compiler = new Perl5Compiler();
+        InvertableMatcher matcher = new InvertableMatcher(new Perl5Matcher());
+        MatchActionProcessor processor = new MatchActionProcessor(compiler, matcher);
+
+        try {
+            int options = Perl5Compiler.DEFAULT_MASK;
+
+            if (ignoreCase) {
+                options = Perl5Compiler.CASE_INSENSITIVE_MASK;
+            }
+
+            processor.addAction(pattern, options, new MatchAction() {
+                public void processMatch(final MatchActionInfo info) {
+                    matches++;
+
+                    // Render output unless --count was configured
+                    if (!count) {
+                        StringBuilder buff = new StringBuilder();
+
+                        if (lineNumbers) {
+                            buff.append(info.lineNumber);
+                            buff.append(":");
+                        }
+
+                        buff.append(info.line);
+
+                        io.info(buff.toString());
+                    }
+                }
+            });
+        }
+        catch (MalformedPatternException e) {
+            io.error("Invalid pattern: " + e, e);
+            return CommandAction.Result.FAILURE;
+        }
+
+        if (path != null) {
+            FileObject file = resolveFile(context, path);
+
+            try {
+                grep(context, processor, file);
+            }
+            finally {
+                FileObjects.close(file);
+            }
+        }
+        else {
+            processor.processMatches(context.getIo().inputStream, context.getIo().outputStream);
+        }
+
+        if (count) {
+            io.info("{}", matches);
+        }
+
+        return matches != 0 ? FOUND: NOT_FOUND;
+    }
+
+    private void grep(final CommandContext context, final MatchActionProcessor processor, final FileObject file) throws Exception {
+        assert context != null;
+        assert processor != null;
+        assert file != null;
+        
+        ensureFileExists(file);
+        ensureFileHasContent(file);
+        ensureFileIsReadable(file);
+
+        BufferedInputStream input = new BufferedInputStream(file.getContent().getInputStream());
+        try {
+            processor.processMatches(input, context.getIo().outputStream);
+        }
+        finally {
+            Closer.close(input);
+        }
+    }
+
+    /**
+     * Delegating {@link PatternMatcher} which allows the match/contains results to be
+     * inverted based on the {@link GrepAction#invertMatch} field for --invert-match support.
+     */
+    private final class InvertableMatcher
+        implements PatternMatcher
+    {
+        private final PatternMatcher delegate;
+
+        public InvertableMatcher(final PatternMatcher delegate) {
+            this.delegate = delegate;
+        }
+
+        public boolean matchesPrefix(char[] input, Pattern pattern, int offset) {
+            boolean result = delegate.matchesPrefix(input, pattern, offset);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean matchesPrefix(String input, Pattern pattern) {
+            boolean result = delegate.matchesPrefix(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean matchesPrefix(char[] input, Pattern pattern) {
+            boolean result = delegate.matchesPrefix(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean matchesPrefix(PatternMatcherInput input, Pattern pattern) {
+            boolean result = delegate.matchesPrefix(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean matches(String input, Pattern pattern) {
+            boolean result = delegate.matches(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean matches(char[] input, Pattern pattern) {
+            boolean result = delegate.matches(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean matches(PatternMatcherInput input, Pattern pattern) {
+            boolean result = delegate.matches(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean contains(String input, Pattern pattern) {
+            boolean result = delegate.contains(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean contains(char[] input, Pattern pattern) {
+            boolean result = delegate.contains(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public boolean contains(PatternMatcherInput input, Pattern pattern) {
+            boolean result = delegate.contains(input, pattern);
+            return invertMatch ? !result : result;
+        }
+
+        public MatchResult getMatch() {
+            return delegate.getMatch();
+        }
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/GrepAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/PrintfAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/PrintfAction.java?rev=721437&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/PrintfAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-textutils/src/main/java/org/apache/geronimo/gshell/commands/textutils/PrintfAction.java Fri Nov 28 03:25:42 2008
@@ -0,0 +1,51 @@
+/*
+ * 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.textutils;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+
+import java.util.Collection;
+
+/**
+ * Prints formatted output.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PrintfAction
+    implements CommandAction
+{
+    @Argument(index=0, required=true)
+    private String format;
+
+    @Argument(index=1, multiValued=true, required=true)
+    private Collection<String> arguments = null;
+
+    public Object execute(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        io.out.printf(format, arguments.toArray());
+        
+        return Result.SUCCESS;
+    }
+}
\ No newline at end of file