Example #1
0
 public function testHelp()
 {
     $application = new Application();
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->setHelp() returns a help message');
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $this->writeText(sprintf("  <info>%-{$width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }