parent
0df0c967a9
commit
3dd9d88e31
@ -0,0 +1,153 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
|
||||
/** |
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> |
||||
*/ |
||||
class ApplicationDescription |
||||
{ |
||||
const GLOBAL_NAMESPACE = '_global'; |
||||
|
||||
/** |
||||
* @var Application |
||||
*/ |
||||
private $application; |
||||
|
||||
/** |
||||
* @var null|string |
||||
*/ |
||||
private $namespace; |
||||
|
||||
/** |
||||
* @var array |
||||
*/ |
||||
private $namespaces; |
||||
|
||||
/** |
||||
* @var Command[] |
||||
*/ |
||||
private $commands; |
||||
|
||||
/** |
||||
* @var Command[] |
||||
*/ |
||||
private $aliases; |
||||
|
||||
/** |
||||
* Constructor. |
||||
* |
||||
* @param Application $application |
||||
* @param string|null $namespace |
||||
*/ |
||||
public function __construct(Application $application, $namespace = null) |
||||
{ |
||||
$this->application = $application; |
||||
$this->namespace = $namespace; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
public function getNamespaces() |
||||
{ |
||||
if (null === $this->namespaces) { |
||||
$this->inspectApplication(); |
||||
} |
||||
|
||||
return $this->namespaces; |
||||
} |
||||
|
||||
/** |
||||
* @return Command[] |
||||
*/ |
||||
public function getCommands() |
||||
{ |
||||
if (null === $this->commands) { |
||||
$this->inspectApplication(); |
||||
} |
||||
|
||||
return $this->commands; |
||||
} |
||||
|
||||
/** |
||||
* @param string $name |
||||
* |
||||
* @return Command |
||||
* |
||||
* @throws \InvalidArgumentException |
||||
*/ |
||||
public function getCommand($name) |
||||
{ |
||||
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { |
||||
throw new \InvalidArgumentException(sprintf('Command %s does not exist.', $name)); |
||||
} |
||||
|
||||
return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; |
||||
} |
||||
|
||||
private function inspectApplication() |
||||
{ |
||||
$this->commands = array(); |
||||
$this->namespaces = array(); |
||||
|
||||
$all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null); |
||||
foreach ($this->sortCommands($all) as $namespace => $commands) { |
||||
$names = array(); |
||||
|
||||
/** @var Command $command */ |
||||
foreach ($commands as $name => $command) { |
||||
if (!$command->getName()) { |
||||
continue; |
||||
} |
||||
|
||||
if ($command->getName() === $name) { |
||||
$this->commands[$name] = $command; |
||||
} else { |
||||
$this->aliases[$name] = $command; |
||||
} |
||||
|
||||
$names[] = $name; |
||||
} |
||||
|
||||
$this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @param array $commands |
||||
* |
||||
* @return array |
||||
*/ |
||||
private function sortCommands(array $commands) |
||||
{ |
||||
$namespacedCommands = array(); |
||||
foreach ($commands as $name => $command) { |
||||
$key = $this->application->extractNamespace($name, 1); |
||||
if (!$key) { |
||||
$key = '_global'; |
||||
} |
||||
|
||||
$namespacedCommands[$key][$name] = $command; |
||||
} |
||||
ksort($namespacedCommands); |
||||
|
||||
foreach ($namespacedCommands as &$commands) { |
||||
ksort($commands); |
||||
} |
||||
|
||||
return $namespacedCommands; |
||||
} |
||||
} |
@ -0,0 +1,92 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
/** |
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> |
||||
*/ |
||||
abstract class Descriptor implements DescriptorInterface |
||||
{ |
||||
public function describe($object, array $options = array()) |
||||
{ |
||||
switch (true) { |
||||
case $object instanceof InputArgument: |
||||
return $this->describeInputArgument($object, $options); |
||||
case $object instanceof InputOption: |
||||
return $this->describeInputOption($object, $options); |
||||
case $object instanceof InputDefinition: |
||||
return $this->describeInputDefinition($object, $options); |
||||
case $object instanceof Command: |
||||
return $this->describeCommand($object, $options); |
||||
case $object instanceof Application: |
||||
return $this->describeApplication($object, $options); |
||||
} |
||||
|
||||
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); |
||||
} |
||||
|
||||
/** |
||||
* Describes an InputArgument instance. |
||||
* |
||||
* @param InputArgument $argument |
||||
* @param array $options |
||||
* |
||||
* @return string|mixed |
||||
*/ |
||||
abstract protected function describeInputArgument(InputArgument $argument, array $options = array()); |
||||
|
||||
/** |
||||
* Describes an InputOption instance. |
||||
* |
||||
* @param InputOption $option |
||||
* @param array $options |
||||
* |
||||
* @return string|mixed |
||||
*/ |
||||
abstract protected function describeInputOption(InputOption $option, array $options = array()); |
||||
|
||||
/** |
||||
* Describes an InputDefinition instance. |
||||
* |
||||
* @param InputDefinition $definition |
||||
* @param array $options |
||||
* |
||||
* @return string|mixed |
||||
*/ |
||||
abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array()); |
||||
|
||||
/** |
||||
* Describes a Command instance. |
||||
* |
||||
* @param Command $command |
||||
* @param array $options |
||||
* |
||||
* @return string|mixed |
||||
*/ |
||||
abstract protected function describeCommand(Command $command, array $options = array()); |
||||
|
||||
/** |
||||
* Describes an Application instance. |
||||
* |
||||
* @param Application $application |
||||
* @param array $options |
||||
* |
||||
* @return string|mixed |
||||
*/ |
||||
abstract protected function describeApplication(Application $application, array $options = array()); |
||||
} |
@ -0,0 +1,30 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
/** |
||||
* Descriptor interface. |
||||
* |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
interface DescriptorInterface |
||||
{ |
||||
/** |
||||
* Describes an InputArgument instance. |
||||
* |
||||
* @param object $object |
||||
* @param array $options |
||||
* |
||||
* @return string|mixed |
||||
*/ |
||||
public function describe($object, array $options = array()); |
||||
} |
@ -0,0 +1,129 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
/** |
||||
* JSON descriptor. |
||||
* |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
class JsonDescriptor extends Descriptor |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputArgument(InputArgument $argument, array $options = array()) |
||||
{ |
||||
return $this->output(array( |
||||
'name' => $argument->getName(), |
||||
'is_required' => $argument->isRequired(), |
||||
'is_array' => $argument->isArray(), |
||||
'description' => $argument->getDescription(), |
||||
'default' => $argument->getDefault(), |
||||
), $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputOption(InputOption $option, array $options = array()) |
||||
{ |
||||
return $this->output(array( |
||||
'name' => '--'.$option->getName(), |
||||
'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '', |
||||
'accept_value' => $option->acceptValue(), |
||||
'is_value_required' => $option->isValueRequired(), |
||||
'is_multiple' => $option->isArray(), |
||||
'description' => $option->getDescription(), |
||||
'default' => $option->getDefault(), |
||||
), $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputDefinition(InputDefinition $definition, array $options = array()) |
||||
{ |
||||
$inputArguments = array(); |
||||
foreach ($definition->getArguments() as $name => $argument) { |
||||
$inputArguments[$name] = $this->describeInputArgument($argument, array('as_array' => true)); |
||||
} |
||||
|
||||
$inputOptions = array(); |
||||
foreach ($definition->getOptions() as $name => $option) { |
||||
$inputOptions[$name] = $this->describeInputOption($option, array('as_array' => true)); |
||||
} |
||||
|
||||
return $this->output(array('arguments' => $inputArguments, 'options' => $inputOptions), $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeCommand(Command $command, array $options = array()) |
||||
{ |
||||
$command->getSynopsis(); |
||||
$command->mergeApplicationDefinition(false); |
||||
|
||||
return $this->output(array( |
||||
'name' => $command->getName(), |
||||
'usage' => $command->getSynopsis(), |
||||
'description' => $command->getDescription(), |
||||
'help' => $command->getProcessedHelp(), |
||||
'aliases' => $command->getAliases(), |
||||
'definition' => $this->describeInputDefinition($command->getNativeDefinition(), array('as_array' => true)), |
||||
), $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeApplication(Application $application, array $options = array()) |
||||
{ |
||||
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
||||
$description = new ApplicationDescription($application, $describedNamespace); |
||||
$commands = array(); |
||||
|
||||
foreach ($description->getCommands() as $command) { |
||||
$commands[] = $this->describeCommand($command, array('as_array' => true)); |
||||
} |
||||
|
||||
$data = $describedNamespace |
||||
? array('commands' => $commands, 'namespace' => $describedNamespace) |
||||
: array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces())); |
||||
|
||||
return $this->output($data, $options); |
||||
} |
||||
|
||||
/** |
||||
* Outputs data as array or string according to options. |
||||
* |
||||
* @param array $data |
||||
* @param array $options |
||||
* |
||||
* @return array|string |
||||
*/ |
||||
private function output(array $data, array $options) |
||||
{ |
||||
if (isset($options['as_array']) && $options['as_array']) { |
||||
return $data; |
||||
} |
||||
|
||||
return json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0); |
||||
} |
||||
} |
@ -0,0 +1,129 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
/** |
||||
* Markdown descriptor. |
||||
* |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
class MarkdownDescriptor extends Descriptor |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputArgument(InputArgument $argument, array $options = array()) |
||||
{ |
||||
return '**'.$argument->getName().':**'."\n\n" |
||||
.'* Name: '.($argument->getName() ?: '<none>')."\n" |
||||
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" |
||||
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n" |
||||
.'* Description: '.($argument->getDescription() ?: '<none>')."\n" |
||||
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputOption(InputOption $option, array $options = array()) |
||||
{ |
||||
return '**'.$option->getName().':**'."\n\n" |
||||
.'* Name: `--'.$option->getName().'`'."\n" |
||||
.'* Shortcut: '.($option->getShortcut() ? '`-'.implode('|-', explode('|', $option->getShortcut())).'`' : '<none>')."\n" |
||||
.'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" |
||||
.'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" |
||||
.'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" |
||||
.'* Description: '.($option->getDescription() ?: '<none>')."\n" |
||||
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputDefinition(InputDefinition $definition, array $options = array()) |
||||
{ |
||||
$blocks = array(); |
||||
|
||||
if (count($definition->getArguments()) > 0) { |
||||
$blocks[] = '### Arguments:'; |
||||
foreach ($definition->getArguments() as $argument) { |
||||
$blocks[] = $this->describeInputArgument($argument); |
||||
} |
||||
} |
||||
|
||||
if (count($definition->getOptions()) > 0) { |
||||
$blocks[] = '### Options:'; |
||||
foreach ($definition->getOptions() as $option) { |
||||
$blocks[] = $this->describeInputOption($option); |
||||
} |
||||
} |
||||
|
||||
return implode("\n\n", $blocks); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeCommand(Command $command, array $options = array()) |
||||
{ |
||||
$command->getSynopsis(); |
||||
$command->mergeApplicationDefinition(false); |
||||
|
||||
$markdown = $command->getName()."\n" |
||||
.str_repeat('-', strlen($command->getName()))."\n\n" |
||||
.'* Description: '.($command->getDescription() ?: '<none>')."\n" |
||||
.'* Usage: `'.$command->getSynopsis().'`'."\n" |
||||
.'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '<none>'); |
||||
|
||||
if ($help = $command->getProcessedHelp()) { |
||||
$markdown .= "\n\n".$help; |
||||
} |
||||
|
||||
if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) { |
||||
$markdown .= "\n\n".$definitionMarkdown; |
||||
} |
||||
|
||||
return $markdown; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeApplication(Application $application, array $options = array()) |
||||
{ |
||||
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
||||
$description = new ApplicationDescription($application, $describedNamespace); |
||||
$blocks = array($application->getName()."\n".str_repeat('=', strlen($application->getName()))); |
||||
|
||||
foreach ($description->getNamespaces() as $namespace) { |
||||
if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { |
||||
$blocks[] = '**'.$namespace['id'].':**'; |
||||
} |
||||
|
||||
$blocks[] = implode("\n", array_map(function ($commandName) { |
||||
return '* '.$commandName; |
||||
} , $namespace['commands'])); |
||||
} |
||||
|
||||
foreach ($description->getCommands() as $command) { |
||||
$blocks[] = $this->describeCommand($command); |
||||
} |
||||
|
||||
return implode("\n\n", $blocks); |
||||
} |
||||
} |
@ -0,0 +1,210 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
/** |
||||
* Text descriptor. |
||||
* |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
class TextDescriptor extends Descriptor |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputArgument(InputArgument $argument, array $options = array()) |
||||
{ |
||||
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) { |
||||
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault())); |
||||
} else { |
||||
$default = ''; |
||||
} |
||||
|
||||
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($argument->getName()); |
||||
$output = str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $argument->getDescription()); |
||||
$output = sprintf(" <info>%-${nameWidth}s</info> %s%s", $argument->getName(), $output, $default); |
||||
|
||||
return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputOption(InputOption $option, array $options = array()) |
||||
{ |
||||
if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { |
||||
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault())); |
||||
} else { |
||||
$default = ''; |
||||
} |
||||
|
||||
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($option->getName()); |
||||
$nameWithShortcutWidth = $nameWidth - strlen($option->getName()) - 2; |
||||
|
||||
$output = sprintf(" <info>%s</info> %-${nameWithShortcutWidth}s%s%s%s", |
||||
'--'.$option->getName(), |
||||
$option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', |
||||
str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $option->getDescription()), |
||||
$default, |
||||
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : '' |
||||
); |
||||
|
||||
return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputDefinition(InputDefinition $definition, array $options = array()) |
||||
{ |
||||
$nameWidth = 0; |
||||
foreach ($definition->getOptions() as $option) { |
||||
$nameLength = strlen($option->getName()) + 2; |
||||
if ($option->getShortcut()) { |
||||
$nameLength += strlen($option->getShortcut()) + 3; |
||||
} |
||||
$nameWidth = max($nameWidth, $nameLength); |
||||
} |
||||
foreach ($definition->getArguments() as $argument) { |
||||
$nameWidth = max($nameWidth, strlen($argument->getName())); |
||||
} |
||||
++$nameWidth; |
||||
|
||||
$messages = array(); |
||||
|
||||
if ($definition->getArguments()) { |
||||
$messages[] = '<comment>Arguments:</comment>'; |
||||
foreach ($definition->getArguments() as $argument) { |
||||
$messages[] = $this->describeInputArgument($argument, array('name_width' => $nameWidth)); |
||||
} |
||||
$messages[] = ''; |
||||
} |
||||
|
||||
if ($definition->getOptions()) { |
||||
$messages[] = '<comment>Options:</comment>'; |
||||
foreach ($definition->getOptions() as $option) { |
||||
$messages[] = $this->describeInputOption($option, array('name_width' => $nameWidth)); |
||||
} |
||||
$messages[] = ''; |
||||
} |
||||
|
||||
$output = implode("\n", $messages); |
||||
|
||||
return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeCommand(Command $command, array $options = array()) |
||||
{ |
||||
$command->getSynopsis(); |
||||
$command->mergeApplicationDefinition(false); |
||||
$messages = array('<comment>Usage:</comment>', ' '.$command->getSynopsis(), ''); |
||||
|
||||
if ($command->getAliases()) { |
||||
$messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $command->getAliases()).'</info>'; |
||||
} |
||||
|
||||
$messages[] = $this->describeInputDefinition($command->getNativeDefinition()); |
||||
|
||||
if ($help = $command->getProcessedHelp()) { |
||||
$messages[] = '<comment>Help:</comment>'; |
||||
$messages[] = ' '.str_replace("\n", "\n ", $help)."\n"; |
||||
} |
||||
|
||||
$output = implode("\n", $messages); |
||||
|
||||
return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeApplication(Application $application, array $options = array()) |
||||
{ |
||||
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
||||
$description = new ApplicationDescription($application, $describedNamespace); |
||||
$messages = array(); |
||||
|
||||
if (isset($options['raw_text']) && $options['raw_text']) { |
||||
$width = $this->getColumnWidth($description->getCommands()); |
||||
|
||||
foreach ($description->getCommands() as $command) { |
||||
$messages[] = sprintf("%-${width}s %s", $command->getName(), $command->getDescription()); |
||||
} |
||||
} else { |
||||
$width = $this->getColumnWidth($description->getCommands()); |
||||
|
||||
$messages[] = $application->getHelp(); |
||||
$messages[] = ''; |
||||
|
||||
if ($describedNamespace) { |
||||
$messages[] = sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace); |
||||
} else { |
||||
$messages[] = '<comment>Available commands:</comment>'; |
||||
} |
||||
|
||||
// add commands by namespace |
||||
foreach ($description->getNamespaces() as $namespace) { |
||||
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { |
||||
$messages[] = '<comment>'.$namespace['id'].'</comment>'; |
||||
} |
||||
|
||||
foreach ($namespace['commands'] as $name) { |
||||
$messages[] = sprintf(" <info>%-${width}s</info> %s", $name, $description->getCommand($name)->getDescription()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$output = implode("\n", $messages); |
||||
|
||||
return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output; |
||||
} |
||||
|
||||
/** |
||||
* Formats input option/argument default value. |
||||
* |
||||
* @param mixed $default |
||||
* |
||||
* @return string |
||||
*/ |
||||
private function formatDefaultValue($default) |
||||
{ |
||||
if (version_compare(PHP_VERSION, '5.4', '<')) { |
||||
return str_replace('\/', '/', json_encode($default)); |
||||
} |
||||
|
||||
return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
||||
} |
||||
|
||||
/** |
||||
* @param Command[] $commands |
||||
* |
||||
* @return int |
||||
*/ |
||||
private function getColumnWidth(array $commands) |
||||
{ |
||||
$width = 0; |
||||
foreach ($commands as $command) { |
||||
$width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; |
||||
} |
||||
|
||||
return $width + 2; |
||||
} |
||||
} |
@ -0,0 +1,212 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
/** |
||||
* XML descriptor. |
||||
* |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
class XmlDescriptor extends Descriptor |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputArgument(InputArgument $argument, array $options = array()) |
||||
{ |
||||
$dom = new \DOMDocument('1.0', 'UTF-8'); |
||||
|
||||
$dom->appendChild($objectXML = $dom->createElement('argument')); |
||||
$objectXML->setAttribute('name', $argument->getName()); |
||||
$objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0); |
||||
$objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0); |
||||
$objectXML->appendChild($descriptionXML = $dom->createElement('description')); |
||||
$descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); |
||||
|
||||
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); |
||||
$defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); |
||||
foreach ($defaults as $default) { |
||||
$defaultsXML->appendChild($defaultXML = $dom->createElement('default')); |
||||
$defaultXML->appendChild($dom->createTextNode($default)); |
||||
} |
||||
|
||||
return $this->output($dom, $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputOption(InputOption $option, array $options = array()) |
||||
{ |
||||
$dom = new \DOMDocument('1.0', 'UTF-8'); |
||||
|
||||
$dom->appendChild($objectXML = $dom->createElement('option')); |
||||
$objectXML->setAttribute('name', '--'.$option->getName()); |
||||
$pos = strpos($option->getShortcut(), '|'); |
||||
if (false !== $pos) { |
||||
$objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos)); |
||||
$objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut()))); |
||||
} else { |
||||
$objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); |
||||
} |
||||
$objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); |
||||
$objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); |
||||
$objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); |
||||
$objectXML->appendChild($descriptionXML = $dom->createElement('description')); |
||||
$descriptionXML->appendChild($dom->createTextNode($option->getDescription())); |
||||
|
||||
if ($option->acceptValue()) { |
||||
$defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); |
||||
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); |
||||
|
||||
if (!empty($defaults)) { |
||||
foreach ($defaults as $default) { |
||||
$defaultsXML->appendChild($defaultXML = $dom->createElement('default')); |
||||
$defaultXML->appendChild($dom->createTextNode($default)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return $this->output($dom, $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeInputDefinition(InputDefinition $definition, array $options = array()) |
||||
{ |
||||
$dom = new \DOMDocument('1.0', 'UTF-8'); |
||||
$dom->appendChild($definitionXML = $dom->createElement('definition')); |
||||
|
||||
$definitionXML->appendChild($argumentsXML = $dom->createElement('arguments')); |
||||
foreach ($definition->getArguments() as $argument) { |
||||
$this->appendDocument($argumentsXML, $this->describeInputArgument($argument, array('as_dom' => true))); |
||||
} |
||||
|
||||
$definitionXML->appendChild($optionsXML = $dom->createElement('options')); |
||||
foreach ($definition->getOptions() as $option) { |
||||
$this->appendDocument($optionsXML, $this->describeInputOption($option, array('as_dom' => true))); |
||||
} |
||||
|
||||
return $this->output($dom, $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeCommand(Command $command, array $options = array()) |
||||
{ |
||||
$dom = new \DOMDocument('1.0', 'UTF-8'); |
||||
$dom->appendChild($commandXML = $dom->createElement('command')); |
||||
|
||||
$command->getSynopsis(); |
||||
$command->mergeApplicationDefinition(false); |
||||
|
||||
$commandXML->setAttribute('id', $command->getName()); |
||||
$commandXML->setAttribute('name', $command->getName()); |
||||
|
||||
$commandXML->appendChild($usageXML = $dom->createElement('usage')); |
||||
$usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), ''))); |
||||
|
||||
$commandXML->appendChild($descriptionXML = $dom->createElement('description')); |
||||
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription()))); |
||||
|
||||
$commandXML->appendChild($helpXML = $dom->createElement('help')); |
||||
$helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp()))); |
||||
|
||||
$commandXML->appendChild($aliasesXML = $dom->createElement('aliases')); |
||||
foreach ($command->getAliases() as $alias) { |
||||
$aliasesXML->appendChild($aliasXML = $dom->createElement('alias')); |
||||
$aliasXML->appendChild($dom->createTextNode($alias)); |
||||
} |
||||
|
||||
$definitionXML = $this->describeInputDefinition($command->getNativeDefinition(), array('as_dom' => true)); |
||||
$this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0)); |
||||
|
||||
return $this->output($dom, $options); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function describeApplication(Application $application, array $options = array()) |
||||
{ |
||||
$dom = new \DOMDocument('1.0', 'UTF-8'); |
||||
$dom->appendChild($rootXml = $dom->createElement('symfony')); |
||||
$rootXml->appendChild($commandsXML = $dom->createElement('commands')); |
||||
|
||||
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
||||
$description = new ApplicationDescription($application, $describedNamespace); |
||||
|
||||
if ($describedNamespace) { |
||||
$commandsXML->setAttribute('namespace', $describedNamespace); |
||||
} |
||||
|
||||
foreach ($description->getCommands() as $command) { |
||||
$this->appendDocument($commandsXML, $this->describeCommand($command, array('as_dom' => true))); |
||||
} |
||||
|
||||
if (!$describedNamespace) { |
||||
$rootXml->appendChild($namespacesXML = $dom->createElement('namespaces')); |
||||
|
||||
foreach ($description->getNamespaces() as $namespace) { |
||||
$namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace')); |
||||
$namespaceArrayXML->setAttribute('id', $namespace['id']); |
||||
|
||||
foreach ($namespace['commands'] as $name) { |
||||
$namespaceArrayXML->appendChild($commandXML = $dom->createElement('command')); |
||||
$commandXML->appendChild($dom->createTextNode($name)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return $this->output($dom, $options); |
||||
} |
||||
|
||||
/** |
||||
* Appends document children to parent node. |
||||
* |
||||
* @param \DOMNode $parentNode |
||||
* @param \DOMNode $importedParent |
||||
*/ |
||||
private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent) |
||||
{ |
||||
foreach ($importedParent->childNodes as $childNode) { |
||||
$parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Outputs document as DOMDocument or string according to options. |
||||
* |
||||
* @param \DOMDocument $dom |
||||
* @param array $options |
||||
* |
||||
* @return \DOMDocument|string |
||||
*/ |
||||
private function output(\DOMDocument $dom, array $options) |
||||
{ |
||||
if (isset($options['as_dom']) && $options['as_dom']) { |
||||
return $dom; |
||||
} |
||||
|
||||
$dom->formatOutput = true; |
||||
|
||||
return $dom->saveXML(); |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Event; |
||||
|
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputInterface; |
||||
use Symfony\Component\Console\Output\OutputInterface; |
||||
|
||||
/** |
||||
* Allows to handle exception thrown in a command. |
||||
* |
||||
* @author Fabien Potencier <fabien@symfony.com> |
||||
*/ |
||||
class ConsoleExceptionEvent extends ConsoleEvent |
||||
{ |
||||
private $exception; |
||||
private $exitCode; |
||||
|
||||
public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode) |
||||
{ |
||||
parent::__construct($command, $input, $output); |
||||
|
||||
$this->setException($exception); |
||||
$this->exitCode = (int) $exitCode; |
||||
} |
||||
|
||||
/** |
||||
* Returns the thrown exception. |
||||
* |
||||
* @return \Exception The thrown exception |
||||
*/ |
||||
public function getException() |
||||
{ |
||||
return $this->exception; |
||||
} |
||||
|
||||
/** |
||||
* Replaces the thrown exception. |
||||
* |
||||
* This exception will be thrown if no response is set in the event. |
||||
* |
||||
* @param \Exception $exception The thrown exception |
||||
*/ |
||||
public function setException(\Exception $exception) |
||||
{ |
||||
$this->exception = $exception; |
||||
} |
||||
|
||||
/** |
||||
* Gets the exit code. |
||||
* |
||||
* @return integer The command exit code |
||||
*/ |
||||
public function getExitCode() |
||||
{ |
||||
return $this->exitCode; |
||||
} |
||||
} |
@ -0,0 +1,95 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Helper; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Descriptor\DescriptorInterface; |
||||
use Symfony\Component\Console\Descriptor\JsonDescriptor; |
||||
use Symfony\Component\Console\Descriptor\MarkdownDescriptor; |
||||
use Symfony\Component\Console\Descriptor\TextDescriptor; |
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
use Symfony\Component\Console\Output\OutputInterface; |
||||
|
||||
/** |
||||
* This class adds helper method to describe objects in various formats. |
||||
* |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
class DescriptorHelper extends Helper |
||||
{ |
||||
/** |
||||
* @var DescriptorInterface[] |
||||
*/ |
||||
private $descriptors = array(); |
||||
|
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$this |
||||
->register('txt', new TextDescriptor()) |
||||
->register('xml', new XmlDescriptor()) |
||||
->register('json', new JsonDescriptor()) |
||||
->register('md', new MarkdownDescriptor()) |
||||
; |
||||
} |
||||
|
||||
/** |
||||
* Describes an object if supported. |
||||
* |
||||
* @param OutputInterface $output |
||||
* @param object $object |
||||
* @param string $format |
||||
* @param boolean $raw |
||||
*/ |
||||
public function describe(OutputInterface $output, $object, $format = null, $raw = false, $namespace = null) |
||||
{ |
||||
$options = array('raw_text' => $raw, 'format' => $format ?: 'txt', 'namespace' => $namespace); |
||||
$type = !$raw && 'txt' === $options['format'] ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW; |
||||
|
||||
if (!isset($this->descriptors[$options['format']])) { |
||||
throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); |
||||
} |
||||
|
||||
$descriptor = $this->descriptors[$options['format']]; |
||||
|
||||
$output->writeln($descriptor->describe($object, $options), $type); |
||||
} |
||||
|
||||
/** |
||||
* Registers a descriptor. |
||||
* |
||||
* @param string $format |
||||
* @param DescriptorInterface $descriptor |
||||
* |
||||
* @return DescriptorHelper |
||||
*/ |
||||
public function register($format, DescriptorInterface $descriptor) |
||||
{ |
||||
$this->descriptors[$format] = $descriptor; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getName() |
||||
{ |
||||
return 'descriptor'; |
||||
} |
||||
} |
@ -0,0 +1,98 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Descriptor\DescriptorInterface; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase |
||||
{ |
||||
/** @dataProvider getDescribeInputArgumentTestData */ |
||||
public function testDescribeInputArgument(InputArgument $argument, $expectedDescription) |
||||
{ |
||||
$this->assertEquals(trim($expectedDescription), trim($this->getDescriptor()->describe($argument))); |
||||
} |
||||
|
||||
/** @dataProvider getDescribeInputOptionTestData */ |
||||
public function testDescribeInputOption(InputOption $option, $expectedDescription) |
||||
{ |
||||
$this->assertEquals(trim($expectedDescription), trim($this->getDescriptor()->describe($option))); |
||||
} |
||||
|
||||
/** @dataProvider getDescribeInputDefinitionTestData */ |
||||
public function testDescribeInputDefinition(InputDefinition $definition, $expectedDescription) |
||||
{ |
||||
$this->assertEquals(trim($expectedDescription), trim($this->getDescriptor()->describe($definition))); |
||||
} |
||||
|
||||
/** @dataProvider getDescribeCommandTestData */ |
||||
public function testDescribeCommand(Command $command, $expectedDescription) |
||||
{ |
||||
$this->assertEquals(trim($expectedDescription), trim($this->getDescriptor()->describe($command))); |
||||
} |
||||
|
||||
/** @dataProvider getDescribeApplicationTestData */ |
||||
public function testDescribeApplication(Application $application, $expectedDescription) |
||||
{ |
||||
// Replaces the dynamic placeholders of the command help text with a static version. |
||||
// The placeholder %command.full_name% includes the script path that is not predictable |
||||
// and can not be tested against. |
||||
foreach ($application->all() as $command) { |
||||
$command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp())); |
||||
} |
||||
|
||||
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $this->getDescriptor()->describe($application)))); |
||||
} |
||||
|
||||
public function getDescribeInputArgumentTestData() |
||||
{ |
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputArguments()); |
||||
} |
||||
|
||||
public function getDescribeInputOptionTestData() |
||||
{ |
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputOptions()); |
||||
} |
||||
|
||||
public function getDescribeInputDefinitionTestData() |
||||
{ |
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions()); |
||||
} |
||||
|
||||
public function getDescribeCommandTestData() |
||||
{ |
||||
return $this->getDescriptionTestData(ObjectsProvider::getCommands()); |
||||
} |
||||
|
||||
public function getDescribeApplicationTestData() |
||||
{ |
||||
return $this->getDescriptionTestData(ObjectsProvider::getApplications()); |
||||
} |
||||
|
||||
abstract protected function getDescriptor(); |
||||
abstract protected function getFormat(); |
||||
|
||||
private function getDescriptionTestData(array $objects) |
||||
{ |
||||
$data = array(); |
||||
foreach ($objects as $name => $object) { |
||||
$description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this->getFormat())); |
||||
$data[] = array($object, $description); |
||||
} |
||||
|
||||
return $data; |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Descriptor\JsonDescriptor; |
||||
|
||||
class JsonDescriptorTest extends AbstractDescriptorTest |
||||
{ |
||||
protected function getDescriptor() |
||||
{ |
||||
return new JsonDescriptor(); |
||||
} |
||||
|
||||
protected function getFormat() |
||||
{ |
||||
return 'json'; |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Descriptor\MarkdownDescriptor; |
||||
|
||||
class MarkdownDescriptorTest extends AbstractDescriptorTest |
||||
{ |
||||
protected function getDescriptor() |
||||
{ |
||||
return new MarkdownDescriptor(); |
||||
} |
||||
|
||||
protected function getFormat() |
||||
{ |
||||
return 'md'; |
||||
} |
||||
} |
@ -0,0 +1,75 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputDefinition; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication1; |
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication2; |
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand1; |
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand2; |
||||
use Symfony\Component\Finder\Shell\Command; |
||||
|
||||
/** |
||||
* @author Jean-François Simon <contact@jfsimon.fr> |
||||
*/ |
||||
class ObjectsProvider |
||||
{ |
||||
public static function getInputArguments() |
||||
{ |
||||
return array( |
||||
'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED), |
||||
'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'), |
||||
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'), |
||||
); |
||||
} |
||||
|
||||
public static function getInputOptions() |
||||
{ |
||||
return array( |
||||
'input_option_1' => new InputOption('option_name', 'o', InputOption::VALUE_NONE), |
||||
'input_option_2' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', 'default_value'), |
||||
'input_option_3' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description'), |
||||
'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', array()), |
||||
); |
||||
} |
||||
|
||||
public static function getInputDefinitions() |
||||
{ |
||||
return array( |
||||
'input_definition_1' => new InputDefinition(), |
||||
'input_definition_2' => new InputDefinition(array(new InputArgument('argument_name', InputArgument::REQUIRED))), |
||||
'input_definition_3' => new InputDefinition(array(new InputOption('option_name', 'o', InputOption::VALUE_NONE))), |
||||
'input_definition_4' => new InputDefinition(array( |
||||
new InputArgument('argument_name', InputArgument::REQUIRED), |
||||
new InputOption('option_name', 'o', InputOption::VALUE_NONE), |
||||
)), |
||||
); |
||||
} |
||||
|
||||
public static function getCommands() |
||||
{ |
||||
return array( |
||||
'command_1' => new DescriptorCommand1(), |
||||
'command_2' => new DescriptorCommand2(), |
||||
); |
||||
} |
||||
|
||||
public static function getApplications() |
||||
{ |
||||
return array( |
||||
'application_1' => new DescriptorApplication1(), |
||||
'application_2' => new DescriptorApplication2(), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor; |
||||
|
||||
class TextDescriptorTest extends AbstractDescriptorTest |
||||
{ |
||||
protected function getDescriptor() |
||||
{ |
||||
return new TextDescriptor(); |
||||
} |
||||
|
||||
protected function getFormat() |
||||
{ |
||||
return 'txt'; |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor; |
||||
|
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor; |
||||
|
||||
class XmlDescriptorTest extends AbstractDescriptorTest |
||||
{ |
||||
protected function getDescriptor() |
||||
{ |
||||
return new XmlDescriptor(); |
||||
} |
||||
|
||||
protected function getFormat() |
||||
{ |
||||
return 'xml'; |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
|
||||
class DescriptorApplication1 extends Application |
||||
{ |
||||
} |
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures; |
||||
|
||||
use Symfony\Component\Console\Application; |
||||
|
||||
class DescriptorApplication2 extends Application |
||||
{ |
||||
public function __construct() |
||||
{ |
||||
parent::__construct('My Symfony application', 'v1.0'); |
||||
$this->add(new DescriptorCommand1()); |
||||
$this->add(new DescriptorCommand2()); |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures; |
||||
|
||||
use Symfony\Component\Console\Command\Command; |
||||
|
||||
class DescriptorCommand1 extends Command |
||||
{ |
||||
protected function configure() |
||||
{ |
||||
$this |
||||
->setName('descriptor:command1') |
||||
->setAliases(array('alias1', 'alias2')) |
||||
->setDescription('command 1 description') |
||||
->setHelp('command 1 help') |
||||
; |
||||
} |
||||
} |
@ -0,0 +1,30 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of the Symfony package. |
||||
* |
||||
* (c) Fabien Potencier <fabien@symfony.com> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures; |
||||
|
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
|
||||
class DescriptorCommand2 extends Command |
||||
{ |
||||
protected function configure() |
||||
{ |
||||
$this |
||||
->setName('descriptor:command2') |
||||
->setDescription('command 2 description') |
||||
->setHelp('command 2 help') |
||||
->addArgument('argument_name', InputArgument::REQUIRED) |
||||
->addOption('option_name', 'o', InputOption::VALUE_NONE) |
||||
; |
||||
} |
||||
} |
@ -0,0 +1 @@ |
||||
{"commands":[{"name":"help","usage":"help [--xml] [--format=\"...\"] [--raw] [command_name]","description":"Displays help for a command","help":"The <info>help<\/info> command displays help for a given command:\n\n <info>php app\/console help list<\/info>\n\nYou can also output the help in other formats by using the <comment>--format<\/comment> option:\n\n <info>php app\/console help --format=xml list<\/info>\n\nTo display the list of available commands, please use the <info>list<\/info> command.","aliases":[],"definition":{"arguments":{"command_name":{"name":"command_name","is_required":false,"is_array":false,"description":"The command name","default":"help"}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output help as XML","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output help in other formats","default":null},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command help","default":false},"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message.","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message.","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version.","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output.","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output.","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question.","default":false}}}},{"name":"list","usage":"list [--xml] [--raw] [--format=\"...\"] [namespace]","description":"Lists commands","help":"The <info>list<\/info> command lists all commands:\n\n <info>php app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n <info>php app\/console list test<\/info>\n\nYou can also output the information in other formats by using the <comment>--format<\/comment> option:\n\n <info>php app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n <info>php app\/console list --raw<\/info>","aliases":[],"definition":{"arguments":{"namespace":{"name":"namespace","is_required":false,"is_array":false,"description":"The namespace name","default":null}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output list as XML","default":false},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command list","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output list in other formats","default":null}}}}],"namespaces":[{"id":"_global","commands":["help","list"]}]} |
@ -0,0 +1,199 @@ |
||||
UNKNOWN |
||||
======= |
||||
|
||||
* help |
||||
* list |
||||
|
||||
help |
||||
---- |
||||
|
||||
* Description: Displays help for a command |
||||
* Usage: `help [--xml] [--format="..."] [--raw] [command_name]` |
||||
* Aliases: <none> |
||||
|
||||
The <info>help</info> command displays help for a given command: |
||||
|
||||
<info>php app/console help list</info> |
||||
|
||||
You can also output the help in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console help --format=xml list</info> |
||||
|
||||
To display the list of available commands, please use the <info>list</info> command. |
||||
|
||||
### Arguments: |
||||
|
||||
**command_name:** |
||||
|
||||
* Name: command_name |
||||
* Is required: no |
||||
* Is array: no |
||||
* Description: The command name |
||||
* Default: `'help'` |
||||
|
||||
### Options: |
||||
|
||||
**xml:** |
||||
|
||||
* Name: `--xml` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output help as XML |
||||
* Default: `false` |
||||
|
||||
**format:** |
||||
|
||||
* Name: `--format` |
||||
* Shortcut: <none> |
||||
* Accept value: yes |
||||
* Is value required: yes |
||||
* Is multiple: no |
||||
* Description: To output help in other formats |
||||
* Default: `NULL` |
||||
|
||||
**raw:** |
||||
|
||||
* Name: `--raw` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output raw command help |
||||
* Default: `false` |
||||
|
||||
**help:** |
||||
|
||||
* Name: `--help` |
||||
* Shortcut: `-h` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this help message. |
||||
* Default: `false` |
||||
|
||||
**quiet:** |
||||
|
||||
* Name: `--quiet` |
||||
* Shortcut: `-q` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not output any message. |
||||
* Default: `false` |
||||
|
||||
**verbose:** |
||||
|
||||
* Name: `--verbose` |
||||
* Shortcut: `-v|-vv|-vvv` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
||||
* Default: `false` |
||||
|
||||
**version:** |
||||
|
||||
* Name: `--version` |
||||
* Shortcut: `-V` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this application version. |
||||
* Default: `false` |
||||
|
||||
**ansi:** |
||||
|
||||
* Name: `--ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Force ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-ansi:** |
||||
|
||||
* Name: `--no-ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Disable ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-interaction:** |
||||
|
||||
* Name: `--no-interaction` |
||||
* Shortcut: `-n` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not ask any interactive question. |
||||
* Default: `false` |
||||
|
||||
list |
||||
---- |
||||
|
||||
* Description: Lists commands |
||||
* Usage: `list [--xml] [--raw] [--format="..."] [namespace]` |
||||
* Aliases: <none> |
||||
|
||||
The <info>list</info> command lists all commands: |
||||
|
||||
<info>php app/console list</info> |
||||
|
||||
You can also display the commands for a specific namespace: |
||||
|
||||
<info>php app/console list test</info> |
||||
|
||||
You can also output the information in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console list --format=xml</info> |
||||
|
||||
It's also possible to get raw list of commands (useful for embedding command runner): |
||||
|
||||
<info>php app/console list --raw</info> |
||||
|
||||
### Arguments: |
||||
|
||||
**namespace:** |
||||
|
||||
* Name: namespace |
||||
* Is required: no |
||||
* Is array: no |
||||
* Description: The namespace name |
||||
* Default: `NULL` |
||||
|
||||
### Options: |
||||
|
||||
**xml:** |
||||
|
||||
* Name: `--xml` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output list as XML |
||||
* Default: `false` |
||||
|
||||
**raw:** |
||||
|
||||
* Name: `--raw` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output raw command list |
||||
* Default: `false` |
||||
|
||||
**format:** |
||||
|
||||
* Name: `--format` |
||||
* Shortcut: <none> |
||||
* Accept value: yes |
||||
* Is value required: yes |
||||
* Is multiple: no |
||||
* Description: To output list in other formats |
||||
* Default: `NULL` |
@ -0,0 +1,17 @@ |
||||
<info>Console Tool</info> |
||||
|
||||
<comment>Usage:</comment> |
||||
[options] command [arguments] |
||||
|
||||
<comment>Options:</comment> |
||||
<info>--help</info> <info>-h</info> Display this help message. |
||||
<info>--quiet</info> <info>-q</info> Do not output any message. |
||||
<info>--verbose</info> <info>-v|vv|vvv</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
||||
<info>--version</info> <info>-V</info> Display this application version. |
||||
<info>--ansi</info> Force ANSI output. |
||||
<info>--no-ansi</info> Disable ANSI output. |
||||
<info>--no-interaction</info> <info>-n</info> Do not ask any interactive question. |
||||
|
||||
<comment>Available commands:</comment> |
||||
<info>help </info> Displays help for a command |
||||
<info>list </info> Lists commands |
@ -0,0 +1,104 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<symfony> |
||||
<commands> |
||||
<command id="help" name="help"> |
||||
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage> |
||||
<description>Displays help for a command</description> |
||||
<help>The <info>help</info> command displays help for a given command: |
||||
|
||||
<info>php app/console help list</info> |
||||
|
||||
You can also output the help in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console help --format=xml list</info> |
||||
|
||||
To display the list of available commands, please use the <info>list</info> command.</help> |
||||
<aliases/> |
||||
<arguments> |
||||
<argument name="command_name" is_required="0" is_array="0"> |
||||
<description>The command name</description> |
||||
<defaults> |
||||
<default>help</default> |
||||
</defaults> |
||||
</argument> |
||||
</arguments> |
||||
<options> |
||||
<option name="--xml" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output help as XML</description> |
||||
</option> |
||||
<option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0"> |
||||
<description>To output help in other formats</description> |
||||
<defaults/> |
||||
</option> |
||||
<option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output raw command help</description> |
||||
</option> |
||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this help message.</description> |
||||
</option> |
||||
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not output any message.</description> |
||||
</option> |
||||
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description> |
||||
</option> |
||||
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this application version.</description> |
||||
</option> |
||||
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Force ANSI output.</description> |
||||
</option> |
||||
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Disable ANSI output.</description> |
||||
</option> |
||||
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not ask any interactive question.</description> |
||||
</option> |
||||
</options> |
||||
</command> |
||||
<command id="list" name="list"> |
||||
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage> |
||||
<description>Lists commands</description> |
||||
<help>The <info>list</info> command lists all commands: |
||||
|
||||
<info>php app/console list</info> |
||||
|
||||
You can also display the commands for a specific namespace: |
||||
|
||||
<info>php app/console list test</info> |
||||
|
||||
You can also output the information in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console list --format=xml</info> |
||||
|
||||
It's also possible to get raw list of commands (useful for embedding command runner): |
||||
|
||||
<info>php app/console list --raw</info></help> |
||||
<aliases/> |
||||
<arguments> |
||||
<argument name="namespace" is_required="0" is_array="0"> |
||||
<description>The namespace name</description> |
||||
<defaults/> |
||||
</argument> |
||||
</arguments> |
||||
<options> |
||||
<option name="--xml" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output list as XML</description> |
||||
</option> |
||||
<option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output raw command list</description> |
||||
</option> |
||||
<option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0"> |
||||
<description>To output list in other formats</description> |
||||
<defaults/> |
||||
</option> |
||||
</options> |
||||
</command> |
||||
</commands> |
||||
<namespaces> |
||||
<namespace id="_global"> |
||||
<command>help</command> |
||||
<command>list</command> |
||||
</namespace> |
||||
</namespaces> |
||||
</symfony> |
File diff suppressed because one or more lines are too long
@ -0,0 +1,388 @@ |
||||
My Symfony application |
||||
====================== |
||||
|
||||
* alias1 |
||||
* alias2 |
||||
* help |
||||
* list |
||||
|
||||
**descriptor:** |
||||
|
||||
* descriptor:command1 |
||||
* descriptor:command2 |
||||
|
||||
help |
||||
---- |
||||
|
||||
* Description: Displays help for a command |
||||
* Usage: `help [--xml] [--format="..."] [--raw] [command_name]` |
||||
* Aliases: <none> |
||||
|
||||
The <info>help</info> command displays help for a given command: |
||||
|
||||
<info>php app/console help list</info> |
||||
|
||||
You can also output the help in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console help --format=xml list</info> |
||||
|
||||
To display the list of available commands, please use the <info>list</info> command. |
||||
|
||||
### Arguments: |
||||
|
||||
**command_name:** |
||||
|
||||
* Name: command_name |
||||
* Is required: no |
||||
* Is array: no |
||||
* Description: The command name |
||||
* Default: `'help'` |
||||
|
||||
### Options: |
||||
|
||||
**xml:** |
||||
|
||||
* Name: `--xml` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output help as XML |
||||
* Default: `false` |
||||
|
||||
**format:** |
||||
|
||||
* Name: `--format` |
||||
* Shortcut: <none> |
||||
* Accept value: yes |
||||
* Is value required: yes |
||||
* Is multiple: no |
||||
* Description: To output help in other formats |
||||
* Default: `NULL` |
||||
|
||||
**raw:** |
||||
|
||||
* Name: `--raw` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output raw command help |
||||
* Default: `false` |
||||
|
||||
**help:** |
||||
|
||||
* Name: `--help` |
||||
* Shortcut: `-h` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this help message. |
||||
* Default: `false` |
||||
|
||||
**quiet:** |
||||
|
||||
* Name: `--quiet` |
||||
* Shortcut: `-q` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not output any message. |
||||
* Default: `false` |
||||
|
||||
**verbose:** |
||||
|
||||
* Name: `--verbose` |
||||
* Shortcut: `-v|-vv|-vvv` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
||||
* Default: `false` |
||||
|
||||
**version:** |
||||
|
||||
* Name: `--version` |
||||
* Shortcut: `-V` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this application version. |
||||
* Default: `false` |
||||
|
||||
**ansi:** |
||||
|
||||
* Name: `--ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Force ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-ansi:** |
||||
|
||||
* Name: `--no-ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Disable ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-interaction:** |
||||
|
||||
* Name: `--no-interaction` |
||||
* Shortcut: `-n` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not ask any interactive question. |
||||
* Default: `false` |
||||
|
||||
list |
||||
---- |
||||
|
||||
* Description: Lists commands |
||||
* Usage: `list [--xml] [--raw] [--format="..."] [namespace]` |
||||
* Aliases: <none> |
||||
|
||||
The <info>list</info> command lists all commands: |
||||
|
||||
<info>php app/console list</info> |
||||
|
||||
You can also display the commands for a specific namespace: |
||||
|
||||
<info>php app/console list test</info> |
||||
|
||||
You can also output the information in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console list --format=xml</info> |
||||
|
||||
It's also possible to get raw list of commands (useful for embedding command runner): |
||||
|
||||
<info>php app/console list --raw</info> |
||||
|
||||
### Arguments: |
||||
|
||||
**namespace:** |
||||
|
||||
* Name: namespace |
||||
* Is required: no |
||||
* Is array: no |
||||
* Description: The namespace name |
||||
* Default: `NULL` |
||||
|
||||
### Options: |
||||
|
||||
**xml:** |
||||
|
||||
* Name: `--xml` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output list as XML |
||||
* Default: `false` |
||||
|
||||
**raw:** |
||||
|
||||
* Name: `--raw` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: To output raw command list |
||||
* Default: `false` |
||||
|
||||
**format:** |
||||
|
||||
* Name: `--format` |
||||
* Shortcut: <none> |
||||
* Accept value: yes |
||||
* Is value required: yes |
||||
* Is multiple: no |
||||
* Description: To output list in other formats |
||||
* Default: `NULL` |
||||
|
||||
descriptor:command1 |
||||
------------------- |
||||
|
||||
* Description: command 1 description |
||||
* Usage: `descriptor:command1` |
||||
* Aliases: `alias1`, `alias2` |
||||
|
||||
command 1 help |
||||
|
||||
### Options: |
||||
|
||||
**help:** |
||||
|
||||
* Name: `--help` |
||||
* Shortcut: `-h` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this help message. |
||||
* Default: `false` |
||||
|
||||
**quiet:** |
||||
|
||||
* Name: `--quiet` |
||||
* Shortcut: `-q` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not output any message. |
||||
* Default: `false` |
||||
|
||||
**verbose:** |
||||
|
||||
* Name: `--verbose` |
||||
* Shortcut: `-v|-vv|-vvv` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
||||
* Default: `false` |
||||
|
||||
**version:** |
||||
|
||||
* Name: `--version` |
||||
* Shortcut: `-V` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this application version. |
||||
* Default: `false` |
||||
|
||||
**ansi:** |
||||
|
||||
* Name: `--ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Force ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-ansi:** |
||||
|
||||
* Name: `--no-ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Disable ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-interaction:** |
||||
|
||||
* Name: `--no-interaction` |
||||
* Shortcut: `-n` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not ask any interactive question. |
||||
* Default: `false` |
||||
|
||||
descriptor:command2 |
||||
------------------- |
||||
|
||||
* Description: command 2 description |
||||
* Usage: `descriptor:command2 [-o|--option_name] argument_name` |
||||
* Aliases: <none> |
||||
|
||||
command 2 help |
||||
|
||||
### Arguments: |
||||
|
||||
**argument_name:** |
||||
|
||||
* Name: argument_name |
||||
* Is required: yes |
||||
* Is array: no |
||||
* Description: <none> |
||||
* Default: `NULL` |
||||
|
||||
### Options: |
||||
|
||||
**option_name:** |
||||
|
||||
* Name: `--option_name` |
||||
* Shortcut: `-o` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: <none> |
||||
* Default: `false` |
||||
|
||||
**help:** |
||||
|
||||
* Name: `--help` |
||||
* Shortcut: `-h` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this help message. |
||||
* Default: `false` |
||||
|
||||
**quiet:** |
||||
|
||||
* Name: `--quiet` |
||||
* Shortcut: `-q` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not output any message. |
||||
* Default: `false` |
||||
|
||||
**verbose:** |
||||
|
||||
* Name: `--verbose` |
||||
* Shortcut: `-v|-vv|-vvv` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
||||
* Default: `false` |
||||
|
||||
**version:** |
||||
|
||||
* Name: `--version` |
||||
* Shortcut: `-V` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Display this application version. |
||||
* Default: `false` |
||||
|
||||
**ansi:** |
||||
|
||||
* Name: `--ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Force ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-ansi:** |
||||
|
||||
* Name: `--no-ansi` |
||||
* Shortcut: <none> |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Disable ANSI output. |
||||
* Default: `false` |
||||
|
||||
**no-interaction:** |
||||
|
||||
* Name: `--no-interaction` |
||||
* Shortcut: `-n` |
||||
* Accept value: no |
||||
* Is value required: no |
||||
* Is multiple: no |
||||
* Description: Do not ask any interactive question. |
||||
* Default: `false` |
@ -0,0 +1,22 @@ |
||||
<info>My Symfony application</info> version <comment>v1.0</comment> |
||||
|
||||
<comment>Usage:</comment> |
||||
[options] command [arguments] |
||||
|
||||
<comment>Options:</comment> |
||||
<info>--help</info> <info>-h</info> Display this help message. |
||||
<info>--quiet</info> <info>-q</info> Do not output any message. |
||||
<info>--verbose</info> <info>-v|vv|vvv</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
||||
<info>--version</info> <info>-V</info> Display this application version. |
||||
<info>--ansi</info> Force ANSI output. |
||||
<info>--no-ansi</info> Disable ANSI output. |
||||
<info>--no-interaction</info> <info>-n</info> Do not ask any interactive question. |
||||
|
||||
<comment>Available commands:</comment> |
||||
<info>alias1 </info> command 1 description |
||||
<info>alias2 </info> command 1 description |
||||
<info>help </info> Displays help for a command |
||||
<info>list </info> Lists commands |
||||
<comment>descriptor</comment> |
||||
<info>descriptor:command1 </info> command 1 description |
||||
<info>descriptor:command2 </info> command 2 description |
@ -0,0 +1,181 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<symfony> |
||||
<commands> |
||||
<command id="help" name="help"> |
||||
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage> |
||||
<description>Displays help for a command</description> |
||||
<help>The <info>help</info> command displays help for a given command: |
||||
|
||||
<info>php app/console help list</info> |
||||
|
||||
You can also output the help in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console help --format=xml list</info> |
||||
|
||||
To display the list of available commands, please use the <info>list</info> command.</help> |
||||
<aliases/> |
||||
<arguments> |
||||
<argument name="command_name" is_required="0" is_array="0"> |
||||
<description>The command name</description> |
||||
<defaults> |
||||
<default>help</default> |
||||
</defaults> |
||||
</argument> |
||||
</arguments> |
||||
<options> |
||||
<option name="--xml" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output help as XML</description> |
||||
</option> |
||||
<option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0"> |
||||
<description>To output help in other formats</description> |
||||
<defaults/> |
||||
</option> |
||||
<option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output raw command help</description> |
||||
</option> |
||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this help message.</description> |
||||
</option> |
||||
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not output any message.</description> |
||||
</option> |
||||
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description> |
||||
</option> |
||||
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this application version.</description> |
||||
</option> |
||||
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Force ANSI output.</description> |
||||
</option> |
||||
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Disable ANSI output.</description> |
||||
</option> |
||||
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not ask any interactive question.</description> |
||||
</option> |
||||
</options> |
||||
</command> |
||||
<command id="list" name="list"> |
||||
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage> |
||||
<description>Lists commands</description> |
||||
<help>The <info>list</info> command lists all commands: |
||||
|
||||
<info>php app/console list</info> |
||||
|
||||
You can also display the commands for a specific namespace: |
||||
|
||||
<info>php app/console list test</info> |
||||
|
||||
You can also output the information in other formats by using the <comment>--format</comment> option: |
||||
|
||||
<info>php app/console list --format=xml</info> |
||||
|
||||
It's also possible to get raw list of commands (useful for embedding command runner): |
||||
|
||||
<info>php app/console list --raw</info></help> |
||||
<aliases/> |
||||
<arguments> |
||||
<argument name="namespace" is_required="0" is_array="0"> |
||||
<description>The namespace name</description> |
||||
<defaults/> |
||||
</argument> |
||||
</arguments> |
||||
<options> |
||||
<option name="--xml" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output list as XML</description> |
||||
</option> |
||||
<option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>To output raw command list</description> |
||||
</option> |
||||
<option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0"> |
||||
<description>To output list in other formats</description> |
||||
<defaults/> |
||||
</option> |
||||
</options> |
||||
</command> |
||||
<command id="descriptor:command1" name="descriptor:command1"> |
||||
<usage>descriptor:command1</usage> |
||||
<description>command 1 description</description> |
||||
<help>command 1 help</help> |
||||
<aliases> |
||||
<alias>alias1</alias> |
||||
<alias>alias2</alias> |
||||
</aliases> |
||||
<arguments/> |
||||
<options> |
||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this help message.</description> |
||||
</option> |
||||
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not output any message.</description> |
||||
</option> |
||||
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description> |
||||
</option> |
||||
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this application version.</description> |
||||
</option> |
||||
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Force ANSI output.</description> |
||||
</option> |
||||
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Disable ANSI output.</description> |
||||
</option> |
||||
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not ask any interactive question.</description> |
||||
</option> |
||||
</options> |
||||
</command> |
||||
<command id="descriptor:command2" name="descriptor:command2"> |
||||
<usage>descriptor:command2 [-o|--option_name] argument_name</usage> |
||||
<description>command 2 description</description> |
||||
<help>command 2 help</help> |
||||
<aliases/> |
||||
<arguments> |
||||
<argument name="argument_name" is_required="1" is_array="0"> |
||||
<description></description> |
||||
<defaults/> |
||||
</argument> |
||||
</arguments> |
||||
<options> |
||||
<option name="--option_name" shortcut="-o" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description></description> |
||||
</option> |
||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this help message.</description> |
||||
</option> |
||||
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not output any message.</description> |
||||
</option> |
||||
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description> |
||||
</option> |
||||
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Display this application version.</description> |
||||
</option> |
||||
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Force ANSI output.</description> |
||||
</option> |
||||
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Disable ANSI output.</description> |
||||
</option> |
||||
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> |
||||
<description>Do not ask any interactive question.</description> |
||||
</option> |
||||
</options> |
||||
</command> |
||||
</commands> |
||||
<namespaces> |
||||
<namespace id="_global"> |
||||
<command>alias1</command> |
||||
<command>alias2</command> |
||||
<command>help</command> |
||||
<command>list</command> |
||||
</namespace> |
||||
<namespace id="descriptor"> |
||||
<command>descriptor:command1</command> |
||||
<command>descriptor:command2</command> |
||||
</namespace> |
||||
</namespaces> |
||||
</symfony> |
@ -0,0 +1 @@ |
||||
{"name":"descriptor:command1","usage":"descriptor:command1","description":"command 1 description","help":"command 1 help","aliases":["alias1","alias2"],"definition":{"arguments":[],"options":[]}} |
@ -0,0 +1,8 @@ |
||||
descriptor:command1 |
||||
------------------- |
||||
|
||||
* Description: command 1 description |
||||
* Usage: `descriptor:command1` |
||||
* Aliases: `alias1`, `alias2` |
||||
|
||||
command 1 help |
@ -0,0 +1,7 @@ |
||||
<comment>Usage:</comment> |
||||
descriptor:command1 |
||||
|
||||
<comment>Aliases:</comment> <info>alias1, alias2</info> |
||||
|
||||
<comment>Help:</comment> |
||||
command 1 help |
@ -0,0 +1,12 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<command id="descriptor:command1" name="descriptor:command1"> |
||||
<usage>descriptor:command1</usage> |
||||
<description>command 1 description</description> |
||||
<help>command 1 help</help> |
||||
<aliases> |
||||
<alias>alias1</alias> |
||||
<alias>alias2</alias> |
||||
</aliases> |
||||
<arguments/> |
||||
<options/> |
||||
</command> |
@ -0,0 +1 @@ |
||||
{"name":"descriptor:command2","usage":"descriptor:command2 [-o|--option_name] argument_name","description":"command 2 description","help":"command 2 help","aliases":[],"definition":{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false}}}} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue