Esempio n. 1
0
 /**
  * Outputs the contents of the file in the template's source path.
  */
 public function readme($file = 'readme.txt')
 {
     $name = str_replace('Generator', '', get_class($this));
     $path = $this->locateGenerator($name);
     if (!file_exists($path . $file)) {
         CLI::error(sprintf(lang('forge.cant_find_readme'), $file));
     }
     $contents = file_get_contents($path . $file);
     CLI::new_line(2);
     CLI::write(CLI::wrap($contents), 'green');
     CLI::new_line();
 }
Esempio n. 2
0
 protected function sayDescriptions($descriptions)
 {
     $names = array_keys($descriptions);
     $syntaxes = array_column($descriptions, 0);
     $descs = array_column($descriptions, 1);
     // Pad each item to the same length
     $names = $this->padArray($names);
     $syntaxes = $this->padArray($syntaxes);
     for ($i = 0; $i < count($names); $i++) {
         $out = CLI::color($names[$i], 'yellow');
         // The rest of the items stay default color.
         if (isset($syntaxes[$i])) {
             $out .= $syntaxes[$i];
         }
         if (isset($descs[$i])) {
             $out .= CLI::wrap($descs[$i], 125, strlen($names[$i]) + strlen($syntaxes[$i]));
         }
         CLI::write($out);
     }
 }
Esempio n. 3
0
 /**
  * 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}");
 }