geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r705587 - /geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java
Date Fri, 17 Oct 2008 12:51:50 GMT
Author: gnodet
Date: Fri Oct 17 05:51:50 2008
New Revision: 705587

URL: http://svn.apache.org/viewvc?rev=705587&view=rev
Log:
Enhance grep command to be able to use the IO input stream when using pipes

Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java?rev=705587&r1=705586&r2=705587&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java
Fri Oct 17 05:51:50 2008
@@ -61,7 +61,7 @@
     @Argument(index=0, required=true)
     private String pattern;
 
-    @Argument(index=1, required=true)
+    @Argument(index=1, required=false)
     private String path;
 
     @Option(name="-c", aliases={"--count"})
@@ -119,13 +119,18 @@
             return Result.FAILURE;
         }
 
-        FileObject file = resolveFile(context, path);
+        if (path != null) {
+            FileObject file = resolveFile(context, path);
 
-        try {
-            grep(context, processor, file);
+            try {
+                grep(context, processor, file);
+            }
+            finally {
+                FileObjects.close(file);
+            }
         }
-        finally {
-            FileObjects.close(file);
+        else {
+            processor.processMatches(context.getIo().inputStream, context.getIo().outputStream);
         }
 
         if (count) {



Mime
View raw message