Skip to content

Commit

Permalink
recursively list flavors
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 8, 2015
1 parent 0f15304 commit e28808a
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/GenPHP/Command/ListCommand.php
Expand Up @@ -7,12 +7,35 @@ function brief() {
return 'list flavors';
}

function options($opts)
public function options($opts)
{
// $opts->add('s|string:','description ....');
}

function execute()

public function traverseDir($path, $parentPath = null)
{
if ( $handle = opendir( $path ) ) {
while (false !== ($entry = readdir($handle))) {
if ( $entry[0] == '.' || $entry == '..' ) {
continue;
}
if ( file_exists($path . DIRECTORY_SEPARATOR . $entry . DIRECTORY_SEPARATOR . 'Resource') ) {
$this->getLogger()->info( sprintf("%-20s %s", $parentPath ? $parentPath . '/' . $entry : $entry, $path), 1 );
} else {
if ( is_dir($path . DIRECTORY_SEPARATOR . $entry) ) {
$this->traverseDir(
$path . DIRECTORY_SEPARATOR . $entry,
$entry
);
}
}
}
closedir($handle);
}
}

public function execute()
{
$logger = $this->getLogger();

Expand All @@ -23,16 +46,7 @@ function execute()
if ( ! file_exists($path) ) {
continue;
}

if ( $handle = opendir( $path ) ) {
while (false !== ($entry = readdir($handle))) {
if ( $entry[0] == '.' || $entry == '..' ) {
continue;
}
$logger->info( sprintf("%-10s %s",$entry, $path), 1 );
}
closedir($handle);
}
$this->traverseDir($path);
}
}
}

0 comments on commit e28808a

Please sign in to comment.