2010-12-23 15:45:53 +01:00
|
|
|
{
|
|
|
|
"name" : "find",
|
|
|
|
|
|
|
|
"info" : {
|
|
|
|
"syntax" : "find <text|regex>",
|
|
|
|
"brief" : "Search for file or directories in the root hierarchy",
|
|
|
|
},
|
|
|
|
|
|
|
|
"action" : function ( arg )
|
|
|
|
{
|
|
|
|
var out = '';
|
|
|
|
|
|
|
|
if ( !arg || arg.length == 0 )
|
|
|
|
{
|
|
|
|
return "Argument required<br/>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( arg.match ( "^['\"](.*)['\"]$" ))
|
|
|
|
{
|
|
|
|
arg = RegExp.$1;
|
|
|
|
}
|
|
|
|
|
2010-12-24 19:09:37 +01:00
|
|
|
var re = new RegExp ( arg, "i" );
|
2010-12-23 15:45:53 +01:00
|
|
|
|
2010-12-29 21:32:43 +01:00
|
|
|
for ( var i in shell.files )
|
2010-12-23 15:45:53 +01:00
|
|
|
{
|
2010-12-29 21:32:43 +01:00
|
|
|
var dir = shell.files[i];
|
2010-12-23 15:45:53 +01:00
|
|
|
|
|
|
|
if ( dir.path.match ( re ))
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( dir.type == 'directory' )
|
|
|
|
{
|
|
|
|
out += '<span class="directory">' + dir.path + "</span><br/>\n";
|
|
|
|
} else if ( dir.type == 'file' && dir.href ) {
|
|
|
|
out += '<span class="file">' +
|
|
|
|
'<a href="' + dir.href + '" target="_new">' +
|
|
|
|
dir.path + "</a></span><br/>\n";
|
|
|
|
} else {
|
|
|
|
out += dir.path + "<br/>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|