[Console] Made output docopt compatible
This commit is contained in:
parent
a630d87d57
commit
39109404da
@ -42,7 +42,8 @@ class Command
|
|||||||
private $applicationDefinitionMerged = false;
|
private $applicationDefinitionMerged = false;
|
||||||
private $applicationDefinitionMergedWithArgs = false;
|
private $applicationDefinitionMergedWithArgs = false;
|
||||||
private $code;
|
private $code;
|
||||||
private $synopsis;
|
private $synopsis = array();
|
||||||
|
private $usages = array();
|
||||||
private $helperSet;
|
private $helperSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,7 +216,8 @@ class Command
|
|||||||
public function run(InputInterface $input, OutputInterface $output)
|
public function run(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
// force the creation of the synopsis before the merge with the app definition
|
// force the creation of the synopsis before the merge with the app definition
|
||||||
$this->getSynopsis();
|
$this->getSynopsis(true);
|
||||||
|
$this->getSynopsis(false);
|
||||||
|
|
||||||
// add the application arguments and options
|
// add the application arguments and options
|
||||||
$this->mergeApplicationDefinition();
|
$this->mergeApplicationDefinition();
|
||||||
@ -573,15 +575,45 @@ class Command
|
|||||||
/**
|
/**
|
||||||
* Returns the synopsis for the command.
|
* Returns the synopsis for the command.
|
||||||
*
|
*
|
||||||
|
* @param bool $short Whether to show the short version of the synopsis (with options folded) or not
|
||||||
|
*
|
||||||
* @return string The synopsis
|
* @return string The synopsis
|
||||||
*/
|
*/
|
||||||
public function getSynopsis()
|
public function getSynopsis($short = false)
|
||||||
{
|
{
|
||||||
if (null === $this->synopsis) {
|
$key = $short ? 'short' : 'long';
|
||||||
$this->synopsis = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis()));
|
|
||||||
|
if (!isset($this->synopsis[$key])) {
|
||||||
|
$this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->synopsis;
|
return $this->synopsis[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a command usage example.
|
||||||
|
*
|
||||||
|
* @param string $usage The usage, it'll be prefixed with the command name
|
||||||
|
*/
|
||||||
|
public function addUsage($usage)
|
||||||
|
{
|
||||||
|
if (0 !== strpos($usage, $this->name)) {
|
||||||
|
$usage = sprintf('%s %s', $this->name, $usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->usages[] = $usage;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns alternative usages of the command.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getUsages()
|
||||||
|
{
|
||||||
|
return $this->usages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
'name' => $argument->getName(),
|
'name' => $argument->getName(),
|
||||||
'is_required' => $argument->isRequired(),
|
'is_required' => $argument->isRequired(),
|
||||||
'is_array' => $argument->isArray(),
|
'is_array' => $argument->isArray(),
|
||||||
'description' => $argument->getDescription(),
|
'description' => preg_replace('/\s*\R\s*/', ' ', $argument->getDescription()),
|
||||||
'default' => $argument->getDefault(),
|
'default' => $argument->getDefault(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
'accept_value' => $option->acceptValue(),
|
'accept_value' => $option->acceptValue(),
|
||||||
'is_value_required' => $option->isValueRequired(),
|
'is_value_required' => $option->isValueRequired(),
|
||||||
'is_multiple' => $option->isArray(),
|
'is_multiple' => $option->isArray(),
|
||||||
'description' => $option->getDescription(),
|
'description' => preg_replace('/\s*\R\s*/', ' ', $option->getDescription()),
|
||||||
'default' => $option->getDefault(),
|
'default' => $option->getDefault(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -157,10 +157,9 @@ class JsonDescriptor extends Descriptor
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
'name' => $command->getName(),
|
'name' => $command->getName(),
|
||||||
'usage' => $command->getSynopsis(),
|
'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
|
||||||
'description' => $command->getDescription(),
|
'description' => $command->getDescription(),
|
||||||
'help' => $command->getProcessedHelp(),
|
'help' => $command->getProcessedHelp(),
|
||||||
'aliases' => $command->getAliases(),
|
|
||||||
'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
|
'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
.'* Name: '.($argument->getName() ?: '<none>')."\n"
|
.'* Name: '.($argument->getName() ?: '<none>')."\n"
|
||||||
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
|
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
|
||||||
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
|
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
|
||||||
.'* Description: '.($argument->getDescription() ?: '<none>')."\n"
|
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $argument->getDescription() ?: '<none>')."\n"
|
||||||
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
|
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
.'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
|
.'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
|
||||||
.'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
|
.'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
|
||||||
.'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
|
.'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
|
||||||
.'* Description: '.($option->getDescription() ?: '<none>')."\n"
|
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $option->getDescription() ?: '<none>')."\n"
|
||||||
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
|
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -96,12 +96,14 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
$command->getName()."\n"
|
$command->getName()."\n"
|
||||||
.str_repeat('-', strlen($command->getName()))."\n\n"
|
.str_repeat('-', strlen($command->getName()))."\n\n"
|
||||||
.'* Description: '.($command->getDescription() ?: '<none>')."\n"
|
.'* Description: '.($command->getDescription() ?: '<none>')."\n"
|
||||||
.'* Usage: `'.$command->getSynopsis().'`'."\n"
|
.'* Usage:'."\n\n"
|
||||||
.'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '<none>')
|
.array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
|
||||||
|
return $carry .= ' * `'.$usage.'`'."\n";
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($help = $command->getProcessedHelp()) {
|
if ($help = $command->getProcessedHelp()) {
|
||||||
$this->write("\n\n");
|
$this->write("\n");
|
||||||
$this->write($help);
|
$this->write($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,16 +32,19 @@ class TextDescriptor extends Descriptor
|
|||||||
protected function describeInputArgument(InputArgument $argument, array $options = array())
|
protected function describeInputArgument(InputArgument $argument, array $options = array())
|
||||||
{
|
{
|
||||||
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
|
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
|
||||||
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault()));
|
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
|
||||||
} else {
|
} else {
|
||||||
$default = '';
|
$default = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($argument->getName());
|
$totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
|
||||||
|
$spacingWidth = $totalWidth - strlen($argument->getName()) + 2;
|
||||||
|
|
||||||
$this->writeText(sprintf(" <info>%-${nameWidth}s</info> %s%s",
|
$this->writeText(sprintf(" <info>%s</info>%s%s%s",
|
||||||
$argument->getName(),
|
$argument->getName(),
|
||||||
str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $argument->getDescription()),
|
str_repeat(' ', $spacingWidth),
|
||||||
|
// + 17 = 2 spaces + <info> + </info> + 2 spaces
|
||||||
|
preg_replace('/\s*\R\s*/', PHP_EOL.str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
|
||||||
$default
|
$default
|
||||||
), $options);
|
), $options);
|
||||||
}
|
}
|
||||||
@ -52,18 +55,33 @@ class TextDescriptor extends Descriptor
|
|||||||
protected function describeInputOption(InputOption $option, array $options = array())
|
protected function describeInputOption(InputOption $option, array $options = array())
|
||||||
{
|
{
|
||||||
if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
|
if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
|
||||||
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault()));
|
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
|
||||||
} else {
|
} else {
|
||||||
$default = '';
|
$default = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($option->getName());
|
$value = '';
|
||||||
$nameWithShortcutWidth = $nameWidth - strlen($option->getName()) - 2;
|
if ($option->acceptValue()) {
|
||||||
|
$value = '='.strtoupper($option->getName());
|
||||||
|
|
||||||
$this->writeText(sprintf(" <info>%s</info> %-${nameWithShortcutWidth}s%s%s%s",
|
if ($option->isValueOptional()) {
|
||||||
'--'.$option->getName(),
|
$value = '['.$value.']';
|
||||||
$option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '',
|
}
|
||||||
str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $option->getDescription()),
|
}
|
||||||
|
|
||||||
|
$totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
|
||||||
|
$synopsis = sprintf('%s%s',
|
||||||
|
$option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
|
||||||
|
sprintf('--%s%s', $option->getName(), $value)
|
||||||
|
);
|
||||||
|
|
||||||
|
$spacingWidth = $totalWidth - strlen($synopsis) + 2;
|
||||||
|
|
||||||
|
$this->writeText(sprintf(" <info>%s</info>%s%s%s%s",
|
||||||
|
$synopsis,
|
||||||
|
str_repeat(' ', $spacingWidth),
|
||||||
|
// + 17 = 2 spaces + <info> + </info> + 2 spaces
|
||||||
|
preg_replace('/\s*\R\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
|
||||||
$default,
|
$default,
|
||||||
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
|
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
|
||||||
), $options);
|
), $options);
|
||||||
@ -74,24 +92,16 @@ class TextDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
protected function describeInputDefinition(InputDefinition $definition, array $options = array())
|
protected function describeInputDefinition(InputDefinition $definition, array $options = array())
|
||||||
{
|
{
|
||||||
$nameWidth = 0;
|
$totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
|
||||||
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) {
|
foreach ($definition->getArguments() as $argument) {
|
||||||
$nameWidth = max($nameWidth, strlen($argument->getName()));
|
$totalWidth = max($totalWidth, strlen($argument->getName()));
|
||||||
}
|
}
|
||||||
++$nameWidth;
|
|
||||||
|
|
||||||
if ($definition->getArguments()) {
|
if ($definition->getArguments()) {
|
||||||
$this->writeText('<comment>Arguments:</comment>', $options);
|
$this->writeText('<comment>Arguments:</comment>', $options);
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
foreach ($definition->getArguments() as $argument) {
|
foreach ($definition->getArguments() as $argument) {
|
||||||
$this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth)));
|
$this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,11 +111,20 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($definition->getOptions()) {
|
if ($definition->getOptions()) {
|
||||||
|
$laterOptions = array();
|
||||||
|
|
||||||
$this->writeText('<comment>Options:</comment>', $options);
|
$this->writeText('<comment>Options:</comment>', $options);
|
||||||
$this->writeText("\n");
|
|
||||||
foreach ($definition->getOptions() as $option) {
|
foreach ($definition->getOptions() as $option) {
|
||||||
$this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth)));
|
if (strlen($option->getShortcut()) > 1) {
|
||||||
|
$laterOptions[] = $option;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
|
$this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
|
||||||
|
}
|
||||||
|
foreach ($laterOptions as $option) {
|
||||||
|
$this->writeText("\n");
|
||||||
|
$this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,27 +134,26 @@ class TextDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
protected function describeCommand(Command $command, array $options = array())
|
protected function describeCommand(Command $command, array $options = array())
|
||||||
{
|
{
|
||||||
$command->getSynopsis();
|
$command->getSynopsis(true);
|
||||||
|
$command->getSynopsis(false);
|
||||||
$command->mergeApplicationDefinition(false);
|
$command->mergeApplicationDefinition(false);
|
||||||
|
|
||||||
$this->writeText('<comment>Usage:</comment>', $options);
|
$this->writeText('<comment>Usage:</comment>', $options);
|
||||||
|
foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
$this->writeText(' '.$command->getSynopsis(), $options);
|
$this->writeText(' '.$usage, $options);
|
||||||
$this->writeText("\n");
|
|
||||||
|
|
||||||
if (count($command->getAliases()) > 0) {
|
|
||||||
$this->writeText("\n");
|
|
||||||
$this->writeText('<comment>Aliases:</comment> <info>'.implode(', ', $command->getAliases()).'</info>', $options);
|
|
||||||
}
|
}
|
||||||
|
$this->writeText("\n");
|
||||||
|
|
||||||
if ($definition = $command->getNativeDefinition()) {
|
$definition = $command->getNativeDefinition();
|
||||||
|
if ($definition->getOptions() || $definition->getArguments()) {
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
$this->describeInputDefinition($definition, $options);
|
$this->describeInputDefinition($definition, $options);
|
||||||
|
$this->writeText("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->writeText("\n");
|
|
||||||
|
|
||||||
if ($help = $command->getProcessedHelp()) {
|
if ($help = $command->getProcessedHelp()) {
|
||||||
|
$this->writeText("\n");
|
||||||
$this->writeText('<comment>Help:</comment>', $options);
|
$this->writeText('<comment>Help:</comment>', $options);
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
$this->writeText(' '.str_replace("\n", "\n ", $help), $options);
|
$this->writeText(' '.str_replace("\n", "\n ", $help), $options);
|
||||||
@ -165,26 +183,11 @@ class TextDescriptor extends Descriptor
|
|||||||
|
|
||||||
$this->writeText("<comment>Usage:</comment>\n", $options);
|
$this->writeText("<comment>Usage:</comment>\n", $options);
|
||||||
$this->writeText(" command [options] [arguments]\n\n", $options);
|
$this->writeText(" command [options] [arguments]\n\n", $options);
|
||||||
$this->writeText('<comment>Options:</comment>', $options);
|
|
||||||
|
|
||||||
$inputOptions = $application->getDefinition()->getOptions();
|
$this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
|
||||||
|
|
||||||
$width = 0;
|
$this->writeText("\n");
|
||||||
foreach ($inputOptions as $option) {
|
$this->writeText("\n");
|
||||||
$nameLength = strlen($option->getName()) + 2;
|
|
||||||
if ($option->getShortcut()) {
|
|
||||||
$nameLength += strlen($option->getShortcut()) + 3;
|
|
||||||
}
|
|
||||||
$width = max($width, $nameLength);
|
|
||||||
}
|
|
||||||
++$width;
|
|
||||||
|
|
||||||
foreach ($inputOptions as $option) {
|
|
||||||
$this->writeText("\n", $options);
|
|
||||||
$this->describeInputOption($option, array_merge($options, array('name_width' => $width)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->writeText("\n\n", $options);
|
|
||||||
|
|
||||||
$width = $this->getColumnWidth($description->getCommands());
|
$width = $this->getColumnWidth($description->getCommands());
|
||||||
|
|
||||||
@ -203,7 +206,8 @@ class TextDescriptor extends Descriptor
|
|||||||
|
|
||||||
foreach ($namespace['commands'] as $name) {
|
foreach ($namespace['commands'] as $name) {
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
$this->writeText(sprintf(" <info>%-${width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
|
$spacingWidth = $width - strlen($name);
|
||||||
|
$this->writeText(sprintf(" <info>%s</info>%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,4 +256,27 @@ class TextDescriptor extends Descriptor
|
|||||||
|
|
||||||
return $width + 2;
|
return $width + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param InputOption[] $options
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function calculateTotalWidthForOptions($options)
|
||||||
|
{
|
||||||
|
$totalWidth = 0;
|
||||||
|
foreach ($options as $option) {
|
||||||
|
$nameLength = 4 + strlen($option->getName()) + 2; // - + shortcut + , + whitespace + name + --
|
||||||
|
|
||||||
|
if ($option->acceptValue()) {
|
||||||
|
$valueLength = 1 + strlen($option->getName()); // = + value
|
||||||
|
$valueLength += $option->isValueOptional() ? 2 : 0; // [ + ]
|
||||||
|
|
||||||
|
$nameLength += $valueLength;
|
||||||
|
}
|
||||||
|
$totalWidth = max($totalWidth, $nameLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $totalWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,11 @@ class XmlDescriptor extends Descriptor
|
|||||||
$commandXML->setAttribute('id', $command->getName());
|
$commandXML->setAttribute('id', $command->getName());
|
||||||
$commandXML->setAttribute('name', $command->getName());
|
$commandXML->setAttribute('name', $command->getName());
|
||||||
|
|
||||||
$commandXML->appendChild($usageXML = $dom->createElement('usage'));
|
$commandXML->appendChild($usagesXML = $dom->createElement('usages'));
|
||||||
$usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), '')));
|
|
||||||
|
foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
|
||||||
|
$usagesXML->appendChild($dom->createElement('usage', $usage));
|
||||||
|
}
|
||||||
|
|
||||||
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
|
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
|
||||||
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
|
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
|
||||||
@ -74,12 +77,6 @@ class XmlDescriptor extends Descriptor
|
|||||||
$commandXML->appendChild($helpXML = $dom->createElement('help'));
|
$commandXML->appendChild($helpXML = $dom->createElement('help'));
|
||||||
$helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
|
$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->getInputDefinitionDocument($command->getNativeDefinition());
|
$definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
|
||||||
$this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
|
$this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
|
||||||
|
|
||||||
|
@ -391,22 +391,50 @@ class InputDefinition
|
|||||||
/**
|
/**
|
||||||
* Gets the synopsis.
|
* Gets the synopsis.
|
||||||
*
|
*
|
||||||
|
* @param bool $short Whether to return the short version (with options foloded) or not
|
||||||
|
*
|
||||||
* @return string The synopsis
|
* @return string The synopsis
|
||||||
*/
|
*/
|
||||||
public function getSynopsis()
|
public function getSynopsis($short = false)
|
||||||
{
|
{
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
||||||
|
if ($short && $this->getOptions()) {
|
||||||
|
$elements[] = '[options]';
|
||||||
|
} elseif (!$short) {
|
||||||
foreach ($this->getOptions() as $option) {
|
foreach ($this->getOptions() as $option) {
|
||||||
|
$value = '';
|
||||||
|
if ($option->acceptValue()) {
|
||||||
|
$value = sprintf(
|
||||||
|
' %s%s%s',
|
||||||
|
$option->isValueOptional() ? '[' : '',
|
||||||
|
strtoupper($option->getName()),
|
||||||
|
$option->isValueOptional() ? ']' : ''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
|
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
|
||||||
$elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName());
|
$elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($elements) && $this->getArguments()) {
|
||||||
|
$elements[] = '[--]';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->getArguments() as $argument) {
|
foreach ($this->getArguments() as $argument) {
|
||||||
$elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : ''));
|
$element = '<'.$argument->getName().'>';
|
||||||
|
if (!$argument->isRequired()) {
|
||||||
|
$element = '['.$element.']';
|
||||||
|
} elseif ($argument->isArray()) {
|
||||||
|
$element = $element.' ('.$element.')';
|
||||||
|
}
|
||||||
|
|
||||||
if ($argument->isArray()) {
|
if ($argument->isArray()) {
|
||||||
$elements[] = sprintf('... [%sN]', $argument->getName());
|
$element .= '...';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$elements[] = $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(' ', $elements);
|
return implode(' ', $elements);
|
||||||
|
@ -154,8 +154,8 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
$command->addOption('foo');
|
$command->addOption('foo');
|
||||||
$command->addArgument('foo');
|
$command->addArgument('bar');
|
||||||
$this->assertEquals('namespace:name [--foo] [foo]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
|
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetHelper()
|
public function testGetHelper()
|
||||||
|
@ -23,8 +23,10 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$command = new HelpCommand();
|
$command = new HelpCommand();
|
||||||
$command->setApplication(new Application());
|
$command->setApplication(new Application());
|
||||||
$commandTester = new CommandTester($command);
|
$commandTester = new CommandTester($command);
|
||||||
$commandTester->execute(array('command_name' => 'li'));
|
$commandTester->execute(array('command_name' => 'li'), array('decorated' => false));
|
||||||
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||||
|
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||||
|
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteForCommand()
|
public function testExecuteForCommand()
|
||||||
@ -32,8 +34,10 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$command = new HelpCommand();
|
$command = new HelpCommand();
|
||||||
$commandTester = new CommandTester($command);
|
$commandTester = new CommandTester($command);
|
||||||
$command->setCommand(new ListCommand());
|
$command->setCommand(new ListCommand());
|
||||||
$commandTester->execute(array());
|
$commandTester->execute(array(), array('decorated' => false));
|
||||||
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
|
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
|
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteForCommandWithXmlOption()
|
public function testExecuteForCommandWithXmlOption()
|
||||||
@ -42,7 +46,7 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$commandTester = new CommandTester($command);
|
$commandTester = new CommandTester($command);
|
||||||
$command->setCommand(new ListCommand());
|
$command->setCommand(new ListCommand());
|
||||||
$commandTester->execute(array('--format' => 'xml'));
|
$commandTester->execute(array('--format' => 'xml'));
|
||||||
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
|
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteForApplicationCommand()
|
public function testExecuteForApplicationCommand()
|
||||||
@ -50,7 +54,9 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$application = new Application();
|
$application = new Application();
|
||||||
$commandTester = new CommandTester($application->get('help'));
|
$commandTester = new CommandTester($application->get('help'));
|
||||||
$commandTester->execute(array('command_name' => 'list'));
|
$commandTester->execute(array('command_name' => 'list'));
|
||||||
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
|
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
|
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteForApplicationCommandWithXmlOption()
|
public function testExecuteForApplicationCommandWithXmlOption()
|
||||||
@ -58,7 +64,7 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$application = new Application();
|
$application = new Application();
|
||||||
$commandTester = new CommandTester($application->get('help'));
|
$commandTester = new CommandTester($application->get('help'));
|
||||||
$commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
|
$commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
|
||||||
$this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
$this->assertContains('list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||||
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
|
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class ListCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
$commandTester = new CommandTester($command = $application->get('list'));
|
$commandTester = new CommandTester($command = $application->get('list'));
|
||||||
$commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
|
$commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
|
||||||
|
|
||||||
$this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
|
$this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteListsCommandsWithXmlOption()
|
public function testExecuteListsCommandsWithXmlOption()
|
||||||
|
@ -96,7 +96,7 @@ abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertDescription($expectedDescription, $describedObject)
|
protected function assertDescription($expectedDescription, $describedObject)
|
||||||
{
|
{
|
||||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||||
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));
|
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||||
|
|
||||||
use Symfony\Component\Console\Descriptor\JsonDescriptor;
|
use Symfony\Component\Console\Descriptor\JsonDescriptor;
|
||||||
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
|
||||||
class JsonDescriptorTest extends AbstractDescriptorTest
|
class JsonDescriptorTest extends AbstractDescriptorTest
|
||||||
{
|
{
|
||||||
@ -24,4 +25,11 @@ class JsonDescriptorTest extends AbstractDescriptorTest
|
|||||||
{
|
{
|
||||||
return 'json';
|
return 'json';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function assertDescription($expectedDescription, $describedObject)
|
||||||
|
{
|
||||||
|
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||||
|
$this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true));
|
||||||
|
$this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ class ObjectsProvider
|
|||||||
'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED),
|
'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED),
|
||||||
'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'),
|
'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'),
|
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
|
||||||
|
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ class ObjectsProvider
|
|||||||
'input_option_2' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', 'default_value'),
|
'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_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()),
|
'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', array()),
|
||||||
|
'input_option_5' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, "multiline\noption description"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ class DescriptorCommand2 extends Command
|
|||||||
->setName('descriptor:command2')
|
->setName('descriptor:command2')
|
||||||
->setDescription('command 2 description')
|
->setDescription('command 2 description')
|
||||||
->setHelp('command 2 help')
|
->setHelp('command 2 help')
|
||||||
|
->addUsage('-o|--option_name <argument_name>')
|
||||||
|
->addUsage('<argument_name>')
|
||||||
->addArgument('argument_name', InputArgument::REQUIRED)
|
->addArgument('argument_name', InputArgument::REQUIRED)
|
||||||
->addOption('option_name', 'o', InputOption::VALUE_NONE)
|
->addOption('option_name', 'o', InputOption::VALUE_NONE)
|
||||||
;
|
;
|
||||||
|
@ -1 +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":"txt"},"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":"txt"}}}}],"namespaces":[{"id":"_global","commands":["help","list"]}]}
|
{"commands":[{"name":"help","usage":["help [--xml] [--format 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.","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":"txt"},"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 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>","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":"txt"}}}}],"namespaces":[{"id":"_global","commands":["help","list"]}]}
|
||||||
|
@ -8,8 +8,9 @@ help
|
|||||||
----
|
----
|
||||||
|
|
||||||
* Description: Displays help for a command
|
* Description: Displays help for a command
|
||||||
* Usage: `help [--xml] [--format="..."] [--raw] [command_name]`
|
* Usage:
|
||||||
* Aliases: <none>
|
|
||||||
|
* `help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]`
|
||||||
|
|
||||||
The <info>help</info> command displays help for a given command:
|
The <info>help</info> command displays help for a given command:
|
||||||
|
|
||||||
@ -137,8 +138,9 @@ list
|
|||||||
----
|
----
|
||||||
|
|
||||||
* Description: Lists commands
|
* Description: Lists commands
|
||||||
* Usage: `list [--xml] [--raw] [--format="..."] [namespace]`
|
* Usage:
|
||||||
* Aliases: <none>
|
|
||||||
|
* `list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]`
|
||||||
|
|
||||||
The <info>list</info> command lists all commands:
|
The <info>list</info> command lists all commands:
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
command [options] [arguments]
|
command [options] [arguments]
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--help</info> (-h) Display this help message
|
<info>-h, --help</info> Display this help message
|
||||||
<info>--quiet</info> (-q) Do not output any message
|
<info>-q, --quiet</info> Do not output any message
|
||||||
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
<info>-V, --version</info> Display this application version
|
||||||
<info>--version</info> (-V) Display this application version
|
|
||||||
<info> --ansi</info> Force ANSI output
|
<info> --ansi</info> Force ANSI output
|
||||||
<info> --no-ansi</info> Disable ANSI output
|
<info> --no-ansi</info> Disable ANSI output
|
||||||
<info>--no-interaction</info> (-n) Do not ask any interactive question
|
<info>-n, --no-interaction</info> Do not ask any interactive question
|
||||||
|
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
<comment>Available commands:</comment>
|
<comment>Available commands:</comment>
|
||||||
<info>help</info> Displays help for a command
|
<info>help</info> Displays help for a command
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
<symfony>
|
<symfony>
|
||||||
<commands>
|
<commands>
|
||||||
<command id="help" name="help">
|
<command id="help" name="help">
|
||||||
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
|
<usages>
|
||||||
|
<usage>help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]</usage>
|
||||||
|
</usages>
|
||||||
<description>Displays help for a command</description>
|
<description>Displays help for a command</description>
|
||||||
<help>The <info>help</info> command displays help for a given command:
|
<help>The <info>help</info> command displays help for a given command:
|
||||||
|
|
||||||
@ -13,7 +15,6 @@
|
|||||||
<info>php app/console help --format=xml list</info>
|
<info>php app/console help --format=xml list</info>
|
||||||
|
|
||||||
To display the list of available commands, please use the <info>list</info> command.</help>
|
To display the list of available commands, please use the <info>list</info> command.</help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="command_name" is_required="0" is_array="0">
|
<argument name="command_name" is_required="0" is_array="0">
|
||||||
<description>The command name</description>
|
<description>The command name</description>
|
||||||
@ -59,7 +60,9 @@
|
|||||||
</options>
|
</options>
|
||||||
</command>
|
</command>
|
||||||
<command id="list" name="list">
|
<command id="list" name="list">
|
||||||
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage>
|
<usages>
|
||||||
|
<usage>list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]</usage>
|
||||||
|
</usages>
|
||||||
<description>Lists commands</description>
|
<description>Lists commands</description>
|
||||||
<help>The <info>list</info> command lists all commands:
|
<help>The <info>list</info> command lists all commands:
|
||||||
|
|
||||||
@ -76,7 +79,6 @@
|
|||||||
It's also possible to get raw list of commands (useful for embedding command runner):
|
It's also possible to get raw list of commands (useful for embedding command runner):
|
||||||
|
|
||||||
<info>php app/console list --raw</info></help>
|
<info>php app/console list --raw</info></help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="namespace" is_required="0" is_array="0">
|
<argument name="namespace" is_required="0" is_array="0">
|
||||||
<description>The namespace name</description>
|
<description>The namespace name</description>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -15,8 +15,9 @@ help
|
|||||||
----
|
----
|
||||||
|
|
||||||
* Description: Displays help for a command
|
* Description: Displays help for a command
|
||||||
* Usage: `help [--xml] [--format="..."] [--raw] [command_name]`
|
* Usage:
|
||||||
* Aliases: <none>
|
|
||||||
|
* `help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]`
|
||||||
|
|
||||||
The <info>help</info> command displays help for a given command:
|
The <info>help</info> command displays help for a given command:
|
||||||
|
|
||||||
@ -144,8 +145,9 @@ list
|
|||||||
----
|
----
|
||||||
|
|
||||||
* Description: Lists commands
|
* Description: Lists commands
|
||||||
* Usage: `list [--xml] [--raw] [--format="..."] [namespace]`
|
* Usage:
|
||||||
* Aliases: <none>
|
|
||||||
|
* `list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]`
|
||||||
|
|
||||||
The <info>list</info> command lists all commands:
|
The <info>list</info> command lists all commands:
|
||||||
|
|
||||||
@ -209,8 +211,11 @@ descriptor:command1
|
|||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
* Description: command 1 description
|
* Description: command 1 description
|
||||||
* Usage: `descriptor:command1`
|
* Usage:
|
||||||
* Aliases: `alias1`, `alias2`
|
|
||||||
|
* `descriptor:command1`
|
||||||
|
* `alias1`
|
||||||
|
* `alias2`
|
||||||
|
|
||||||
command 1 help
|
command 1 help
|
||||||
|
|
||||||
@ -290,8 +295,11 @@ descriptor:command2
|
|||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
* Description: command 2 description
|
* Description: command 2 description
|
||||||
* Usage: `descriptor:command2 [-o|--option_name] argument_name`
|
* Usage:
|
||||||
* Aliases: <none>
|
|
||||||
|
* `descriptor:command2 [-o|--option_name] [--] <argument_name>`
|
||||||
|
* `descriptor:command2 -o|--option_name <argument_name>`
|
||||||
|
* `descriptor:command2 <argument_name>`
|
||||||
|
|
||||||
command 2 help
|
command 2 help
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
command [options] [arguments]
|
command [options] [arguments]
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--help</info> (-h) Display this help message
|
<info>-h, --help</info> Display this help message
|
||||||
<info>--quiet</info> (-q) Do not output any message
|
<info>-q, --quiet</info> Do not output any message
|
||||||
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
<info>-V, --version</info> Display this application version
|
||||||
<info>--version</info> (-V) Display this application version
|
|
||||||
<info> --ansi</info> Force ANSI output
|
<info> --ansi</info> Force ANSI output
|
||||||
<info> --no-ansi</info> Disable ANSI output
|
<info> --no-ansi</info> Disable ANSI output
|
||||||
<info>--no-interaction</info> (-n) Do not ask any interactive question
|
<info>-n, --no-interaction</info> Do not ask any interactive question
|
||||||
|
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
<comment>Available commands:</comment>
|
<comment>Available commands:</comment>
|
||||||
<info>alias1</info> command 1 description
|
<info>alias1</info> command 1 description
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
<symfony name="My Symfony application" version="v1.0">
|
<symfony name="My Symfony application" version="v1.0">
|
||||||
<commands>
|
<commands>
|
||||||
<command id="help" name="help">
|
<command id="help" name="help">
|
||||||
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
|
<usages>
|
||||||
|
<usage>help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]</usage>
|
||||||
|
</usages>
|
||||||
<description>Displays help for a command</description>
|
<description>Displays help for a command</description>
|
||||||
<help>The <info>help</info> command displays help for a given command:
|
<help>The <info>help</info> command displays help for a given command:
|
||||||
|
|
||||||
@ -13,7 +15,6 @@
|
|||||||
<info>php app/console help --format=xml list</info>
|
<info>php app/console help --format=xml list</info>
|
||||||
|
|
||||||
To display the list of available commands, please use the <info>list</info> command.</help>
|
To display the list of available commands, please use the <info>list</info> command.</help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="command_name" is_required="0" is_array="0">
|
<argument name="command_name" is_required="0" is_array="0">
|
||||||
<description>The command name</description>
|
<description>The command name</description>
|
||||||
@ -59,7 +60,9 @@
|
|||||||
</options>
|
</options>
|
||||||
</command>
|
</command>
|
||||||
<command id="list" name="list">
|
<command id="list" name="list">
|
||||||
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage>
|
<usages>
|
||||||
|
<usage>list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]</usage>
|
||||||
|
</usages>
|
||||||
<description>Lists commands</description>
|
<description>Lists commands</description>
|
||||||
<help>The <info>list</info> command lists all commands:
|
<help>The <info>list</info> command lists all commands:
|
||||||
|
|
||||||
@ -76,7 +79,6 @@
|
|||||||
It's also possible to get raw list of commands (useful for embedding command runner):
|
It's also possible to get raw list of commands (useful for embedding command runner):
|
||||||
|
|
||||||
<info>php app/console list --raw</info></help>
|
<info>php app/console list --raw</info></help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="namespace" is_required="0" is_array="0">
|
<argument name="namespace" is_required="0" is_array="0">
|
||||||
<description>The namespace name</description>
|
<description>The namespace name</description>
|
||||||
@ -99,13 +101,13 @@
|
|||||||
</options>
|
</options>
|
||||||
</command>
|
</command>
|
||||||
<command id="descriptor:command1" name="descriptor:command1">
|
<command id="descriptor:command1" name="descriptor:command1">
|
||||||
|
<usages>
|
||||||
<usage>descriptor:command1</usage>
|
<usage>descriptor:command1</usage>
|
||||||
|
<usage>alias1</usage>
|
||||||
|
<usage>alias2</usage>
|
||||||
|
</usages>
|
||||||
<description>command 1 description</description>
|
<description>command 1 description</description>
|
||||||
<help>command 1 help</help>
|
<help>command 1 help</help>
|
||||||
<aliases>
|
|
||||||
<alias>alias1</alias>
|
|
||||||
<alias>alias2</alias>
|
|
||||||
</aliases>
|
|
||||||
<arguments/>
|
<arguments/>
|
||||||
<options>
|
<options>
|
||||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
|
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
|
||||||
@ -132,10 +134,13 @@
|
|||||||
</options>
|
</options>
|
||||||
</command>
|
</command>
|
||||||
<command id="descriptor:command2" name="descriptor:command2">
|
<command id="descriptor:command2" name="descriptor:command2">
|
||||||
<usage>descriptor:command2 [-o|--option_name] argument_name</usage>
|
<usages>
|
||||||
|
<usage>descriptor:command2 [-o|--option_name] [--] <argument_name></usage>
|
||||||
|
<usage>descriptor:command2 -o|--option_name <argument_name></usage>
|
||||||
|
<usage>descriptor:command2 <argument_name></usage>
|
||||||
|
</usages>
|
||||||
<description>command 2 description</description>
|
<description>command 2 description</description>
|
||||||
<help>command 2 help</help>
|
<help>command 2 help</help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="argument_name" is_required="1" is_array="0">
|
<argument name="argument_name" is_required="1" is_array="0">
|
||||||
<description></description>
|
<description></description>
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
command [options] [arguments]
|
command [options] [arguments]
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--help</info> (-h) Display this help message
|
<info>-h, --help</info> Display this help message
|
||||||
<info>--quiet</info> (-q) Do not output any message
|
<info>-q, --quiet</info> Do not output any message
|
||||||
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
<info>-V, --version</info> Display this application version
|
||||||
<info>--version</info> (-V) Display this application version
|
|
||||||
<info> --ansi</info> Force ANSI output
|
<info> --ansi</info> Force ANSI output
|
||||||
<info> --no-ansi</info> Disable ANSI output
|
<info> --no-ansi</info> Disable ANSI output
|
||||||
<info>--no-interaction</info> (-n) Do not ask any interactive question
|
<info>-n, --no-interaction</info> Do not ask any interactive question
|
||||||
|
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
<comment>Available commands:</comment>
|
<comment>Available commands:</comment>
|
||||||
<info>afoobar</info> The foo:bar command
|
<info>afoobar</info> The foo:bar command
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
command [options] [arguments]
|
command [options] [arguments]
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--help</info> (-h) Display this help message
|
<info>-h, --help</info> Display this help message
|
||||||
<info>--quiet</info> (-q) Do not output any message
|
<info>-q, --quiet</info> Do not output any message
|
||||||
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
<info>-V, --version</info> Display this application version
|
||||||
<info>--version</info> (-V) Display this application version
|
|
||||||
<info> --ansi</info> Force ANSI output
|
<info> --ansi</info> Force ANSI output
|
||||||
<info> --no-ansi</info> Disable ANSI output
|
<info> --no-ansi</info> Disable ANSI output
|
||||||
<info>--no-interaction</info> (-n) Do not ask any interactive question
|
<info>-n, --no-interaction</info> Do not ask any interactive question
|
||||||
|
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
<comment>Available commands for the "foo" namespace:</comment>
|
<comment>Available commands for the "foo" namespace:</comment>
|
||||||
<info>foo:bar</info> The foo:bar command
|
<info>foo:bar</info> The foo:bar command
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
<symfony>
|
<symfony>
|
||||||
<commands>
|
<commands>
|
||||||
<command id="help" name="help">
|
<command id="help" name="help">
|
||||||
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
|
<usages>
|
||||||
|
<usage>help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]</usage>
|
||||||
|
</usages>
|
||||||
<description>Displays help for a command</description>
|
<description>Displays help for a command</description>
|
||||||
<help>The <info>help</info> command displays help for a given command:
|
<help>The <info>help</info> command displays help for a given command:
|
||||||
|
|
||||||
@ -13,7 +15,6 @@
|
|||||||
<info>php app/console help --format=xml list</info>
|
<info>php app/console help --format=xml list</info>
|
||||||
|
|
||||||
To display the list of available commands, please use the <info>list</info> command.</help>
|
To display the list of available commands, please use the <info>list</info> command.</help>
|
||||||
<aliases />
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="command_name" is_required="0" is_array="0">
|
<argument name="command_name" is_required="0" is_array="0">
|
||||||
<description>The command name</description>
|
<description>The command name</description>
|
||||||
@ -59,7 +60,9 @@
|
|||||||
</options>
|
</options>
|
||||||
</command>
|
</command>
|
||||||
<command id="list" name="list">
|
<command id="list" name="list">
|
||||||
<usage>list [--xml] [--raw] [--format="..."] [namespace]</usage>
|
<usages>
|
||||||
|
<usage>list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]</usage>
|
||||||
|
</usages>
|
||||||
<description>Lists commands</description>
|
<description>Lists commands</description>
|
||||||
<help>The <info>list</info> command lists all commands:
|
<help>The <info>list</info> command lists all commands:
|
||||||
|
|
||||||
@ -76,7 +79,6 @@
|
|||||||
It's also possible to get raw list of commands (useful for embedding command runner):
|
It's also possible to get raw list of commands (useful for embedding command runner):
|
||||||
|
|
||||||
<info>php app/console list --raw</info></help>
|
<info>php app/console list --raw</info></help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="namespace" is_required="0" is_array="0">
|
<argument name="namespace" is_required="0" is_array="0">
|
||||||
<description>The namespace name</description>
|
<description>The namespace name</description>
|
||||||
@ -99,12 +101,12 @@
|
|||||||
</options>
|
</options>
|
||||||
</command>
|
</command>
|
||||||
<command id="foo:bar" name="foo:bar">
|
<command id="foo:bar" name="foo:bar">
|
||||||
|
<usages>
|
||||||
<usage>foo:bar</usage>
|
<usage>foo:bar</usage>
|
||||||
|
<usage>afoobar</usage>
|
||||||
|
</usages>
|
||||||
<description>The foo:bar command</description>
|
<description>The foo:bar command</description>
|
||||||
<help/>
|
<help/>
|
||||||
<aliases>
|
|
||||||
<alias>afoobar</alias>
|
|
||||||
</aliases>
|
|
||||||
<arguments/>
|
<arguments/>
|
||||||
<options>
|
<options>
|
||||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
|
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
<symfony>
|
<symfony>
|
||||||
<commands namespace="foo">
|
<commands namespace="foo">
|
||||||
<command id="foo:bar" name="foo:bar">
|
<command id="foo:bar" name="foo:bar">
|
||||||
|
<usages>
|
||||||
<usage>foo:bar</usage>
|
<usage>foo:bar</usage>
|
||||||
|
<usage>afoobar</usage>
|
||||||
|
</usages>
|
||||||
<description>The foo:bar command</description>
|
<description>The foo:bar command</description>
|
||||||
<help/>
|
<help/>
|
||||||
<aliases>
|
|
||||||
<alias>afoobar</alias>
|
|
||||||
</aliases>
|
|
||||||
<arguments/>
|
<arguments/>
|
||||||
<options>
|
<options>
|
||||||
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
|
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
|
||||||
|
@ -6,6 +6,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
list [--xml] [--raw] [--format="..."] [namespace]
|
list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ Usage:
|
|||||||
command [options] [arguments]
|
command [options] [arguments]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help (-h) Display this help message
|
-h, --help Display this help message
|
||||||
--quiet (-q) Do not output any message
|
-q, --quiet Do not output any message
|
||||||
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
-V, --version Display this application version
|
||||||
--version (-V) Display this application version
|
|
||||||
--ansi Force ANSI output
|
--ansi Force ANSI output
|
||||||
--no-ansi Disable ANSI output
|
--no-ansi Disable ANSI output
|
||||||
--no-interaction (-n) Do not ask any interactive question
|
-n, --no-interaction Do not ask any interactive question
|
||||||
|
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
Available commands:
|
Available commands:
|
||||||
help Displays help for a command
|
help Displays help for a command
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
Usage:
|
Usage:
|
||||||
help [--xml] [--format="..."] [--raw] [command_name]
|
help [options] [--] [<command_name>]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
command The command to execute
|
command The command to execute
|
||||||
command_name The command name (default: "help")
|
command_name The command name [default: "help"]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--xml To output help as XML
|
--xml To output help as XML
|
||||||
--format To output help in other formats (default: "txt")
|
--format=FORMAT To output help in other formats [default: "txt"]
|
||||||
--raw To output raw command help
|
--raw To output raw command help
|
||||||
--help (-h) Display this help message
|
-h, --help Display this help message
|
||||||
--quiet (-q) Do not output any message
|
-q, --quiet Do not output any message
|
||||||
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
-V, --version Display this application version
|
||||||
--version (-V) Display this application version
|
|
||||||
--ansi Force ANSI output
|
--ansi Force ANSI output
|
||||||
--no-ansi Disable ANSI output
|
--no-ansi Disable ANSI output
|
||||||
--no-interaction (-n) Do not ask any interactive question
|
-n, --no-interaction Do not ask any interactive question
|
||||||
|
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
Help:
|
Help:
|
||||||
The help command displays help for a given command:
|
The help command displays help for a given command:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Usage:
|
Usage:
|
||||||
list [--xml] [--raw] [--format="..."] [namespace]
|
list [options] [--] [<namespace>]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
namespace The namespace name
|
namespace The namespace name
|
||||||
@ -7,7 +7,7 @@ Arguments:
|
|||||||
Options:
|
Options:
|
||||||
--xml To output list as XML
|
--xml To output list as XML
|
||||||
--raw To output raw command list
|
--raw To output raw command list
|
||||||
--format To output list in other formats (default: "txt")
|
--format=FORMAT To output list in other formats [default: "txt"]
|
||||||
|
|
||||||
Help:
|
Help:
|
||||||
The list command lists all commands:
|
The list command lists all commands:
|
||||||
|
@ -1 +1 @@
|
|||||||
{"name":"descriptor:command1","usage":"descriptor:command1","description":"command 1 description","help":"command 1 help","aliases":["alias1","alias2"],"definition":{"arguments":[],"options":[]}}
|
{"name":"descriptor:command1","usage":["descriptor:command1", "alias1", "alias2"],"description":"command 1 description","help":"command 1 help","definition":{"arguments":[],"options":[]}}
|
||||||
|
@ -2,7 +2,10 @@ descriptor:command1
|
|||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
* Description: command 1 description
|
* Description: command 1 description
|
||||||
* Usage: `descriptor:command1`
|
* Usage:
|
||||||
* Aliases: `alias1`, `alias2`
|
|
||||||
|
* `descriptor:command1`
|
||||||
|
* `alias1`
|
||||||
|
* `alias2`
|
||||||
|
|
||||||
command 1 help
|
command 1 help
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<comment>Usage:</comment>
|
<comment>Usage:</comment>
|
||||||
descriptor:command1
|
descriptor:command1
|
||||||
|
alias1
|
||||||
<comment>Aliases:</comment> <info>alias1, alias2</info>
|
alias2
|
||||||
|
|
||||||
<comment>Help:</comment>
|
<comment>Help:</comment>
|
||||||
command 1 help
|
command 1 help
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<command id="descriptor:command1" name="descriptor:command1">
|
<command id="descriptor:command1" name="descriptor:command1">
|
||||||
|
<usages>
|
||||||
<usage>descriptor:command1</usage>
|
<usage>descriptor:command1</usage>
|
||||||
|
<usage>alias1</usage>
|
||||||
|
<usage>alias2</usage>
|
||||||
|
</usages>
|
||||||
<description>command 1 description</description>
|
<description>command 1 description</description>
|
||||||
<help>command 1 help</help>
|
<help>command 1 help</help>
|
||||||
<aliases>
|
|
||||||
<alias>alias1</alias>
|
|
||||||
<alias>alias2</alias>
|
|
||||||
</aliases>
|
|
||||||
<arguments/>
|
<arguments/>
|
||||||
<options/>
|
<options/>
|
||||||
</command>
|
</command>
|
||||||
|
@ -1 +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}}}}
|
{"name":"descriptor:command2","usage":["descriptor:command2 [-o|--option_name] [--] <argument_name>", "descriptor:command2 -o|--option_name <argument_name>", "descriptor:command2 <argument_name>"],"description":"command 2 description","help":"command 2 help","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}}}}
|
||||||
|
@ -2,8 +2,11 @@ descriptor:command2
|
|||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
* Description: command 2 description
|
* Description: command 2 description
|
||||||
* Usage: `descriptor:command2 [-o|--option_name] argument_name`
|
* Usage:
|
||||||
* Aliases: <none>
|
|
||||||
|
* `descriptor:command2 [-o|--option_name] [--] <argument_name>`
|
||||||
|
* `descriptor:command2 -o|--option_name <argument_name>`
|
||||||
|
* `descriptor:command2 <argument_name>`
|
||||||
|
|
||||||
command 2 help
|
command 2 help
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<comment>Usage:</comment>
|
<comment>Usage:</comment>
|
||||||
descriptor:command2 [-o|--option_name] argument_name
|
descriptor:command2 [options] [--] <argument_name>
|
||||||
|
descriptor:command2 -o|--option_name <argument_name>
|
||||||
|
descriptor:command2 <argument_name>
|
||||||
|
|
||||||
<comment>Arguments:</comment>
|
<comment>Arguments:</comment>
|
||||||
<info>argument_name</info>
|
<info>argument_name</info>
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--option_name</info> (-o)
|
<info>-o, --option_name</info>
|
||||||
|
|
||||||
<comment>Help:</comment>
|
<comment>Help:</comment>
|
||||||
command 2 help
|
command 2 help
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<command id="descriptor:command2" name="descriptor:command2">
|
<command id="descriptor:command2" name="descriptor:command2">
|
||||||
<usage>descriptor:command2 [-o|--option_name] argument_name</usage>
|
<usages>
|
||||||
|
<usage>descriptor:command2 [-o|--option_name] [--] <argument_name></usage>
|
||||||
|
<usage>descriptor:command2 -o|--option_name <argument_name></usage>
|
||||||
|
<usage>descriptor:command2 <argument_name></usage>
|
||||||
|
</usages>
|
||||||
<description>command 2 description</description>
|
<description>command 2 description</description>
|
||||||
<help>command 2 help</help>
|
<help>command 2 help</help>
|
||||||
<aliases/>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="argument_name" is_required="1" is_array="0">
|
<argument name="argument_name" is_required="1" is_array="0">
|
||||||
<description></description>
|
<description></description>
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<comment>Usage:</comment>
|
<comment>Usage:</comment>
|
||||||
namespace:name
|
namespace:name
|
||||||
|
name
|
||||||
|
|
||||||
<comment>Aliases:</comment> <info>name</info>
|
|
||||||
<comment>Arguments:</comment>
|
<comment>Arguments:</comment>
|
||||||
<info>command</info> The command to execute
|
<info>command</info> The command to execute
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--help</info> (-h) Display this help message
|
<info>-h, --help</info> Display this help message
|
||||||
<info>--quiet</info> (-q) Do not output any message
|
<info>-q, --quiet</info> Do not output any message
|
||||||
<info>--verbose</info> (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
<info>-V, --version</info> Display this application version
|
||||||
<info>--version</info> (-V) Display this application version
|
|
||||||
<info> --ansi</info> Force ANSI output
|
<info> --ansi</info> Force ANSI output
|
||||||
<info> --no-ansi</info> Disable ANSI output
|
<info> --no-ansi</info> Disable ANSI output
|
||||||
<info>--no-interaction</info> (-n) Do not ask any interactive question
|
<info>-n, --no-interaction</info> Do not ask any interactive question
|
||||||
|
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
<comment>Help:</comment>
|
<comment>Help:</comment>
|
||||||
help
|
help
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<command id="namespace:name" name="namespace:name">
|
<command id="namespace:name" name="namespace:name">
|
||||||
|
<usages>
|
||||||
<usage>namespace:name</usage>
|
<usage>namespace:name</usage>
|
||||||
|
<usage>name</usage>
|
||||||
|
</usages>
|
||||||
<description>description</description>
|
<description>description</description>
|
||||||
<help>help</help>
|
<help>help</help>
|
||||||
<aliases>
|
|
||||||
<alias>name</alias>
|
|
||||||
</aliases>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument name="command" is_required="1" is_array="0">
|
<argument name="command" is_required="1" is_array="0">
|
||||||
<description>The command to execute</description>
|
<description>The command to execute</description>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<comment>Arguments:</comment>
|
<comment>Arguments:</comment>
|
||||||
<info>foo</info> The foo argument
|
<info>foo</info> The foo argument
|
||||||
<info>baz </info> The baz argument<comment> (default: true)</comment>
|
<info>baz</info> The baz argument<comment> [default: true]</comment>
|
||||||
<info>bar </info> The bar argument<comment> (default: ["http://foo.com/"])</comment>
|
<info>bar</info> The bar argument<comment> [default: ["http://foo.com/"]]</comment>
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--foo</info> (-f) The foo option
|
<info>-f, --foo=FOO</info> The foo option
|
||||||
<info>--baz</info> The baz option<comment> (default: false)</comment>
|
<info> --baz[=BAZ]</info> The baz option<comment> [default: false]</comment>
|
||||||
<info>--bar</info> (-b) The bar option<comment> (default: "bar")</comment>
|
<info>-b, --bar[=BAR]</info> The bar option<comment> [default: "bar"]</comment>
|
||||||
<info>--qux</info> The qux option<comment> (default: ["http://foo.com/","bar"])</comment><comment> (multiple values allowed)</comment>
|
<info> --qux[=QUX]</info> The qux option<comment> [default: ["http://foo.com/","bar"]]</comment><comment> (multiple values allowed)</comment>
|
||||||
<info>--qux2</info> The qux2 option<comment> (default: {"foo":"bar"})</comment><comment> (multiple values allowed)</comment>
|
<info> --qux2[=QUX2]</info> The qux2 option<comment> [default: {"foo":"bar"}]</comment><comment> (multiple values allowed)</comment>
|
@ -1 +1 @@
|
|||||||
<info>argument_name</info> argument description<comment> (default: "default_value")</comment>
|
<info>argument_name</info> argument description<comment> [default: "default_value"]</comment>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{"name":"argument_name","is_required":true,"is_array":false,"description":"multiline argument description","default":null}
|
@ -0,0 +1,8 @@
|
|||||||
|
**argument_name:**
|
||||||
|
|
||||||
|
* Name: argument_name
|
||||||
|
* Is required: yes
|
||||||
|
* Is array: no
|
||||||
|
* Description: multiline
|
||||||
|
argument description
|
||||||
|
* Default: `NULL`
|
@ -0,0 +1,2 @@
|
|||||||
|
<info>argument_name</info> multiline
|
||||||
|
argument description
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<argument name="argument_name" is_required="1" is_array="0">
|
||||||
|
<description>multiline
|
||||||
|
argument description</description>
|
||||||
|
<defaults/>
|
||||||
|
</argument>
|
@ -1,2 +1,2 @@
|
|||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--option_name</info> (-o)
|
<info>-o, --option_name</info>
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
<info>argument_name</info>
|
<info>argument_name</info>
|
||||||
|
|
||||||
<comment>Options:</comment>
|
<comment>Options:</comment>
|
||||||
<info>--option_name</info> (-o)
|
<info>-o, --option_name</info>
|
||||||
|
@ -1 +1 @@
|
|||||||
<info>--option_name</info> (-o)
|
<info>-o, --option_name</info>
|
||||||
|
@ -1 +1 @@
|
|||||||
<info>--option_name</info> (-o) option description<comment> (default: "default_value")</comment>
|
<info>-o, --option_name[=OPTION_NAME]</info> option description<comment> [default: "default_value"]</comment>
|
||||||
|
@ -1 +1 @@
|
|||||||
<info>--option_name</info> (-o) option description
|
<info>-o, --option_name=OPTION_NAME</info> option description
|
||||||
|
@ -1 +1 @@
|
|||||||
<info>--option_name</info> (-o) option description<comment> (multiple values allowed)</comment>
|
<info>-o, --option_name[=OPTION_NAME]</info> option description<comment> (multiple values allowed)</comment>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{"name":"--option_name","shortcut":"-o","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"multiline option description","default":null}
|
@ -0,0 +1,10 @@
|
|||||||
|
**option_name:**
|
||||||
|
|
||||||
|
* Name: `--option_name`
|
||||||
|
* Shortcut: `-o`
|
||||||
|
* Accept value: yes
|
||||||
|
* Is value required: yes
|
||||||
|
* Is multiple: no
|
||||||
|
* Description: multiline
|
||||||
|
option description
|
||||||
|
* Default: `NULL`
|
@ -0,0 +1,2 @@
|
|||||||
|
<info>-o, --option_name=OPTION_NAME</info> multiline
|
||||||
|
option description
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<option name="--option_name" shortcut="-o" accept_value="1" is_value_required="1" is_multiple="0">
|
||||||
|
<description>multiline
|
||||||
|
option description</description>
|
||||||
|
<defaults/>
|
||||||
|
</option>
|
@ -352,25 +352,35 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($defaults, $definition->getOptionDefaults(), '->getOptionDefaults() returns the default values for all options');
|
$this->assertEquals($defaults, $definition->getOptionDefaults(), '->getOptionDefaults() returns the default values for all options');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSynopsis()
|
/**
|
||||||
|
* @dataProvider getGetSynopsisData
|
||||||
|
*/
|
||||||
|
public function testGetSynopsis(InputDefinition $definition, $expectedSynopsis, $message = null)
|
||||||
{
|
{
|
||||||
$definition = new InputDefinition(array(new InputOption('foo')));
|
$this->assertEquals($expectedSynopsis, $definition->getSynopsis(), $message ? '->getSynopsis() '.$message : '');
|
||||||
$this->assertEquals('[--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
}
|
||||||
$definition = new InputDefinition(array(new InputOption('foo', 'f')));
|
|
||||||
$this->assertEquals('[-f|--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
|
||||||
$definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)));
|
|
||||||
$this->assertEquals('[-f|--foo="..."]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
|
||||||
$definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)));
|
|
||||||
$this->assertEquals('[-f|--foo[="..."]]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
|
||||||
|
|
||||||
$definition = new InputDefinition(array(new InputArgument('foo')));
|
public function getGetSynopsisData()
|
||||||
$this->assertEquals('[foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
{
|
||||||
$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED)));
|
return array(
|
||||||
$this->assertEquals('foo', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
array(new InputDefinition(array(new InputOption('foo'))), '[--foo]', 'puts optional options in square brackets'),
|
||||||
$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY)));
|
array(new InputDefinition(array(new InputOption('foo', 'f'))), '[-f|--foo]', 'separates shortcut with a pipe'),
|
||||||
$this->assertEquals('[foo1] ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
array(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), '[-f|--foo FOO]', 'uses shortcut as value placeholder'),
|
||||||
$definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY)));
|
array(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))), '[-f|--foo [FOO]]', 'puts optional values in square brackets'),
|
||||||
$this->assertEquals('foo1 ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
|
||||||
|
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))), '<foo>', 'puts arguments in angle brackets'),
|
||||||
|
array(new InputDefinition(array(new InputArgument('foo'))), '[<foo>]', 'puts optional arguments in square brackets'),
|
||||||
|
array(new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))), '[<foo>]...', 'uses an ellipsis for array arguments'),
|
||||||
|
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))), '<foo> (<foo>)...', 'uses parenthesis and ellipsis for required array arguments'),
|
||||||
|
|
||||||
|
array(new InputDefinition(array(new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED))), '[--foo] [--] <foo>', 'puts [--] between options and arguments'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetShortSynopsis()
|
||||||
|
{
|
||||||
|
$definition = new InputDefinition(array(new InputOption('foo'), new InputOption('bar'), new InputArgument('cat')));
|
||||||
|
$this->assertEquals('[options] [--] [<cat>]', $definition->getSynopsis(true), '->getSynopsis(true) groups options in [options]');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLegacyAsText()
|
public function testLegacyAsText()
|
||||||
@ -387,6 +397,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
new InputOption('qux', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux option', array('http://foo.com/', 'bar')),
|
new InputOption('qux', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux option', array('http://foo.com/', 'bar')),
|
||||||
new InputOption('qux2', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux2 option', array('foo' => 'bar')),
|
new InputOption('qux2', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux2 option', array('foo' => 'bar')),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertStringEqualsFile(self::$fixtures.'/definition_astext.txt', $definition->asText(), '->asText() returns a textual representation of the InputDefinition');
|
$this->assertStringEqualsFile(self::$fixtures.'/definition_astext.txt', $definition->asText(), '->asText() returns a textual representation of the InputDefinition');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,6 +986,13 @@ HTML;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCountOfNestedElements()
|
||||||
|
{
|
||||||
|
$crawler = new Crawler('<html><body><ul><li>List item 1<ul><li>Sublist item 1</li><li>Sublist item 2</ul></li></ul></body></html>');
|
||||||
|
|
||||||
|
$this->assertCount(1, $crawler->filter('li:contains("List item 1")'));
|
||||||
|
}
|
||||||
|
|
||||||
public function createTestCrawler($uri = null)
|
public function createTestCrawler($uri = null)
|
||||||
{
|
{
|
||||||
$dom = new \DOMDocument();
|
$dom = new \DOMDocument();
|
||||||
|
Reference in New Issue
Block a user