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/09/28 17:50:00 UTC
svn commit: r699843 - in
/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main:
java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
resources/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.properties
Author: jdillon
Date: Sun Sep 28 08:49:59 2008
New Revision: 699843
URL: http://svn.apache.org/viewvc?rev=699843&view=rev
Log:
Add -a flag to show files which start with ".", dont' show them by default
Modified:
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.properties
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java?rev=699843&r1=699842&r2=699843&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java Sun Sep 28 08:49:59 2008
@@ -23,6 +23,9 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.FileFilter;
+import org.apache.commons.vfs.FileSelectInfo;
+import org.apache.commons.vfs.FileFilterSelector;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandContext;
@@ -42,7 +45,10 @@
@Argument
private String path;
- @Option(name="-r", aliases={ "--recursive" })
+ @Option(name="-a")
+ private boolean includeHidden = false;
+
+ @Option(name="-r", aliases={"--recursive"})
private boolean recursive = false;
public Object execute(final CommandContext context) throws Exception {
@@ -79,15 +85,26 @@
assert dir != null;
assert prefix != null;
- for (FileObject child : dir.getChildren()) {
+ FileFilter filter = new FileFilter() {
+ public boolean accept(final FileSelectInfo selection) {
+ assert selection != null;
+
+ // When includeHidden only include the file if there is not "." prefix, else include everything
+ return includeHidden || !selection.getFile().getName().getBaseName().startsWith(".");
+ }
+ };
+
+ FileObject[] files = dir.findFiles(new FileFilterSelector(filter));
+
+ for (FileObject file : files) {
io.out.print(prefix);
- io.out.print(child.getName().getBaseName());
+ io.out.print(file.getName().getBaseName());
- if (child.getType() == FileType.FOLDER) {
+ if (file.getType() == FileType.FOLDER) {
io.out.println("/");
if (recursive) {
- listChildren(io, child, recursive, prefix + " ");
+ listChildren(io, file, recursive, prefix + " ");
}
}
else {
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.properties?rev=699843&r1=699842&r2=699843&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.properties (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.properties Sun Sep 28 08:49:59 2008
@@ -28,6 +28,8 @@
command.argument.path=The file or directory path to list.
command.argument.path.token=PATH
+command.option.includeHidden=Include directory entries whose names begin with a dot '.'
+
command.option.recursive=List the contents of directories recursivly
command.manual=\