예제 #1
0
파일: Forge.php 프로젝트: leloulight/Sprint
 /**
  * Overrides CLIController's version to support searching our
  * collections for the help description.
  *
  * @param null $method
  */
 public function longDescribeMethod($method = null)
 {
     $collections = config_item('forge.collections');
     if (!is_array($collections) || !count($collections)) {
         return CLI::error('No generator collections found.');
     }
     // We loop through each collection scanning
     // for any generator folders that have a
     // 'forge.php' file. For each one found
     // we build out another section in our help commands
     foreach ($collections as $alias => $path) {
         $path = rtrim($path, '/ ') . '/';
         $folders = scandir($path);
         if (!($i = array_search(ucfirst($method), $folders))) {
             continue;
         }
         $dir = $path . $folders[$i] . '/';
         if (!is_file($dir . '/forge.php')) {
             CLI::error("The {$method} command does not have any cli help available.");
         }
         include $dir . '/forge.php';
         // Don't have valid arrays to work with? Move along...
         if (!isset($long_description)) {
             log_message('debug', '[Forge] Invalid forge.php file at: ' . $dir . '/forge.php');
             continue;
         }
         if (empty($long_description)) {
             return CLI::error("The {$method} command does not have an cli help available.");
         }
         CLI::new_line();
         CLI::write(CLI::color(ucfirst($method) . ' Help', 'yellow'));
         return CLI::write(CLI::wrap($long_description, CLI::getWidth()));
     }
     // Still here?
     CLI::error("No help found for command: {$method}");
 }