feature #39642 [Console] Support binary / negatable options (greg-1-anderson, jderusse)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[Console] Support binary / negatable options

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #24314
| License       | MIT
| Doc PR        | TODO

This PR take over #26292 to introduce a new option mode `NEGATABLE` that ease creation of option and their negation (ie. `--foo`, `--no-foo`)

Negated options applies only to flag options (`VALUE_NONE`)
```
./cli.php --foo
var_dump(getOption('foo')); // true

./cli.php --no-foo
var_dump(getOption('foo')); // false
```

Commits
-------

1a9a3c34c9 Implement negatable option
8d455dbd0c [WIP] Implements #24314: Support binary / negatable options, e.g. --foo and --no-foo.
This commit is contained in:
Fabien Potencier 2021-01-05 08:59:18 +01:00
commit a0bbf53ebb
44 changed files with 360 additions and 176 deletions

View File

@ -1033,8 +1033,7 @@ class Application implements ResetInterface
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'), new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'), new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'), new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
]); ]);
} }

View File

@ -5,6 +5,7 @@ CHANGELOG
----- -----
* Added `GithubActionReporter` to render annotations in a Github Action * Added `GithubActionReporter` to render annotations in a Github Action
* Added `InputOption::VALUE_NEGATABLE` flag to handle `--foo`/`--no-foo` options.
5.2.0 5.2.0
----- -----

View File

@ -40,6 +40,9 @@ class JsonDescriptor extends Descriptor
protected function describeInputOption(InputOption $option, array $options = []) protected function describeInputOption(InputOption $option, array $options = [])
{ {
$this->writeData($this->getInputOptionData($option), $options); $this->writeData($this->getInputOptionData($option), $options);
if ($option->isNegatable()) {
$this->writeData($this->getInputOptionData($option, true), $options);
}
} }
/** /**
@ -111,9 +114,17 @@ class JsonDescriptor extends Descriptor
]; ];
} }
private function getInputOptionData(InputOption $option): array private function getInputOptionData(InputOption $option, bool $negated = false): array
{ {
return [ return $negated ? [
'name' => '--no-'.$option->getName(),
'shortcut' => '',
'accept_value' => false,
'is_value_required' => false,
'is_multiple' => false,
'description' => 'Negate the "--'.$option->getName().'" option',
'default' => false,
] : [
'name' => '--'.$option->getName(), 'name' => '--'.$option->getName(),
'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
'accept_value' => $option->acceptValue(), 'accept_value' => $option->acceptValue(),
@ -134,6 +145,9 @@ class JsonDescriptor extends Descriptor
$inputOptions = []; $inputOptions = [];
foreach ($definition->getOptions() as $name => $option) { foreach ($definition->getOptions() as $name => $option) {
$inputOptions[$name] = $this->getInputOptionData($option); $inputOptions[$name] = $this->getInputOptionData($option);
if ($option->isNegatable()) {
$inputOptions['no-'.$name] = $this->getInputOptionData($option, true);
}
} }
return ['arguments' => $inputArguments, 'options' => $inputOptions]; return ['arguments' => $inputArguments, 'options' => $inputOptions];

View File

@ -69,6 +69,9 @@ class MarkdownDescriptor extends Descriptor
protected function describeInputOption(InputOption $option, array $options = []) protected function describeInputOption(InputOption $option, array $options = [])
{ {
$name = '--'.$option->getName(); $name = '--'.$option->getName();
if ($option->isNegatable()) {
$name .= '|--no-'.$option->getName();
}
if ($option->getShortcut()) { if ($option->getShortcut()) {
$name .= '|-'.str_replace('|', '|-', $option->getShortcut()).''; $name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
} }
@ -79,6 +82,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"
.'* Is negatable: '.($option->isNegatable() ? 'yes' : 'no')."\n"
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`' .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
); );
} }

View File

@ -74,7 +74,7 @@ class TextDescriptor extends Descriptor
$totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]); $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
$synopsis = sprintf('%s%s', $synopsis = sprintf('%s%s',
$option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
sprintf('--%s%s', $option->getName(), $value) sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)
); );
$spacingWidth = $totalWidth - Helper::strlen($synopsis); $spacingWidth = $totalWidth - Helper::strlen($synopsis);
@ -325,8 +325,9 @@ class TextDescriptor extends Descriptor
foreach ($options as $option) { foreach ($options as $option) {
// "-" + shortcut + ", --" + name // "-" + shortcut + ", --" + name
$nameLength = 1 + max(Helper::strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName()); $nameLength = 1 + max(Helper::strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
if ($option->isNegatable()) {
if ($option->acceptValue()) { $nameLength += 6 + Helper::strlen($option->getName()); // |--no- + name
} elseif ($option->acceptValue()) {
$valueLength = 1 + Helper::strlen($option->getName()); // = + value $valueLength = 1 + Helper::strlen($option->getName()); // = + value
$valueLength += $option->isValueOptional() ? 2 : 0; // [ + ] $valueLength += $option->isValueOptional() ? 2 : 0; // [ + ]

View File

@ -225,6 +225,17 @@ class XmlDescriptor extends Descriptor
} }
} }
if ($option->isNegatable()) {
$dom->appendChild($objectXML = $dom->createElement('option'));
$objectXML->setAttribute('name', '--no-'.$option->getName());
$objectXML->setAttribute('shortcut', '');
$objectXML->setAttribute('accept_value', 0);
$objectXML->setAttribute('is_value_required', 0);
$objectXML->setAttribute('is_multiple', 0);
$objectXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createTextNode('Negate the "--'.$option->getName().'" option'));
}
return $dom; return $dom;
} }
} }

View File

@ -209,9 +209,19 @@ class ArgvInput extends Input
private function addLongOption(string $name, $value) private function addLongOption(string $name, $value)
{ {
if (!$this->definition->hasOption($name)) { if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name)); throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
} }
$optionName = $this->definition->negationToName($name);
if (null !== $value) {
throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
}
$this->options[$optionName] = false;
return;
}
$option = $this->definition->getOption($name); $option = $this->definition->getOption($name);
if (null !== $value && !$option->acceptValue()) { if (null !== $value && !$option->acceptValue()) {

View File

@ -165,9 +165,16 @@ class ArrayInput extends Input
private function addLongOption(string $name, $value) private function addLongOption(string $name, $value)
{ {
if (!$this->definition->hasOption($name)) { if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name)); throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
} }
$optionName = $this->definition->negationToName($name);
$this->options[$optionName] = false;
return;
}
$option = $this->definition->getOption($name); $option = $this->definition->getOption($name);
if (null === $value) { if (null === $value) {

View File

@ -33,6 +33,7 @@ class InputDefinition
private $hasAnArrayArgument = false; private $hasAnArrayArgument = false;
private $hasOptional; private $hasOptional;
private $options; private $options;
private $negations;
private $shortcuts; private $shortcuts;
/** /**
@ -208,6 +209,7 @@ class InputDefinition
{ {
$this->options = []; $this->options = [];
$this->shortcuts = []; $this->shortcuts = [];
$this->negations = [];
$this->addOptions($options); $this->addOptions($options);
} }
@ -246,6 +248,14 @@ class InputDefinition
$this->shortcuts[$shortcut] = $option->getName(); $this->shortcuts[$shortcut] = $option->getName();
} }
} }
if ($option->isNegatable()) {
$negatedName = 'no-'.$option->getName();
if (isset($this->options[$negatedName])) {
throw new LogicException(sprintf('An option named "%s" already exists.', $negatedName));
}
$this->negations[$negatedName] = $option->getName();
}
} }
/** /**
@ -297,6 +307,14 @@ class InputDefinition
return isset($this->shortcuts[$name]); return isset($this->shortcuts[$name]);
} }
/**
* Returns true if an InputOption object exists by negated name.
*/
public function hasNegation(string $name): bool
{
return isset($this->negations[$name]);
}
/** /**
* Gets an InputOption by shortcut. * Gets an InputOption by shortcut.
* *
@ -338,6 +356,22 @@ class InputDefinition
return $this->shortcuts[$shortcut]; return $this->shortcuts[$shortcut];
} }
/**
* Returns the InputOption name given a negation.
*
* @throws InvalidArgumentException When option given does not exist
*
* @internal
*/
public function negationToName(string $negation): string
{
if (!isset($this->negations[$negation])) {
throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $negation));
}
return $this->negations[$negation];
}
/** /**
* Gets the synopsis. * Gets the synopsis.
* *
@ -362,7 +396,8 @@ class InputDefinition
} }
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
$elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value); $negation = $option->isNegatable() ? sprintf('|--no-%s', $option->getName()) : '';
$elements[] = sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
} }
} }

View File

@ -25,6 +25,7 @@ class InputOption
public const VALUE_REQUIRED = 2; public const VALUE_REQUIRED = 2;
public const VALUE_OPTIONAL = 4; public const VALUE_OPTIONAL = 4;
public const VALUE_IS_ARRAY = 8; public const VALUE_IS_ARRAY = 8;
public const VALUE_NEGATABLE = 16;
private $name; private $name;
private $shortcut; private $shortcut;
@ -70,7 +71,7 @@ class InputOption
if (null === $mode) { if (null === $mode) {
$mode = self::VALUE_NONE; $mode = self::VALUE_NONE;
} elseif ($mode > 15 || $mode < 1) { } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
} }
@ -82,6 +83,9 @@ class InputOption
if ($this->isArray() && !$this->acceptValue()) { if ($this->isArray() && !$this->acceptValue()) {
throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
} }
if ($this->isNegatable() && $this->acceptValue()) {
throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
}
$this->setDefault($default); $this->setDefault($default);
} }
@ -146,6 +150,11 @@ class InputOption
return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
} }
public function isNegatable(): bool
{
return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
}
/** /**
* Sets the default value. * Sets the default value.
* *
@ -158,6 +167,9 @@ class InputOption
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
} }
if (self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode) && null !== $default) {
throw new LogicException('Cannot set a default value when using InputOption::VALUE_NEGATABLE mode.');
}
if ($this->isArray()) { if ($this->isArray()) {
if (null === $default) { if (null === $default) {
@ -200,6 +212,7 @@ class InputOption
return $option->getName() === $this->getName() return $option->getName() === $this->getName()
&& $option->getShortcut() === $this->getShortcut() && $option->getShortcut() === $this->getShortcut()
&& $option->getDefault() === $this->getDefault() && $option->getDefault() === $this->getDefault()
&& $option->isNegatable() === $this->isNegatable()
&& $option->isArray() === $this->isArray() && $option->isArray() === $this->isArray()
&& $option->isValueRequired() === $this->isValueRequired() && $option->isValueRequired() === $this->isValueRequired()
&& $option->isValueOptional() === $this->isValueOptional() && $option->isValueOptional() === $this->isValueOptional()

View File

@ -1257,7 +1257,8 @@ class ApplicationTest extends TestCase
$this->assertTrue($inputDefinition->hasOption('verbose')); $this->assertTrue($inputDefinition->hasOption('verbose'));
$this->assertTrue($inputDefinition->hasOption('version')); $this->assertTrue($inputDefinition->hasOption('version'));
$this->assertTrue($inputDefinition->hasOption('ansi')); $this->assertTrue($inputDefinition->hasOption('ansi'));
$this->assertTrue($inputDefinition->hasOption('no-ansi')); $this->assertTrue($inputDefinition->hasNegation('no-ansi'));
$this->assertFalse($inputDefinition->hasOption('no-ansi'));
$this->assertTrue($inputDefinition->hasOption('no-interaction')); $this->assertTrue($inputDefinition->hasOption('no-interaction'));
} }
@ -1277,7 +1278,7 @@ class ApplicationTest extends TestCase
$this->assertFalse($inputDefinition->hasOption('verbose')); $this->assertFalse($inputDefinition->hasOption('verbose'));
$this->assertFalse($inputDefinition->hasOption('version')); $this->assertFalse($inputDefinition->hasOption('version'));
$this->assertFalse($inputDefinition->hasOption('ansi')); $this->assertFalse($inputDefinition->hasOption('ansi'));
$this->assertFalse($inputDefinition->hasOption('no-ansi')); $this->assertFalse($inputDefinition->hasNegation('no-ansi'));
$this->assertFalse($inputDefinition->hasOption('no-interaction')); $this->assertFalse($inputDefinition->hasOption('no-interaction'));
$this->assertTrue($inputDefinition->hasOption('custom')); $this->assertTrue($inputDefinition->hasOption('custom'));
@ -1301,7 +1302,7 @@ class ApplicationTest extends TestCase
$this->assertFalse($inputDefinition->hasOption('verbose')); $this->assertFalse($inputDefinition->hasOption('verbose'));
$this->assertFalse($inputDefinition->hasOption('version')); $this->assertFalse($inputDefinition->hasOption('version'));
$this->assertFalse($inputDefinition->hasOption('ansi')); $this->assertFalse($inputDefinition->hasOption('ansi'));
$this->assertFalse($inputDefinition->hasOption('no-ansi')); $this->assertFalse($inputDefinition->hasNegation('no-ansi'));
$this->assertFalse($inputDefinition->hasOption('no-interaction')); $this->assertFalse($inputDefinition->hasOption('no-interaction'));
$this->assertTrue($inputDefinition->hasOption('custom')); $this->assertTrue($inputDefinition->hasOption('custom'));

View File

@ -80,8 +80,7 @@ Options:
-h, --help Display help for the given command. When no command is given display help for the list command -h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message -q, --quiet Do not output any message
-V, --version Display this application version -V, --version Display this application version
--ansi Force ANSI output --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction 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 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -79,7 +79,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -88,7 +88,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {
@ -182,7 +182,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -191,7 +191,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {

View File

@ -42,6 +42,7 @@ The output format (txt, xml, json, or md)
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'txt'` * Default: `'txt'`
#### `--raw` #### `--raw`
@ -51,6 +52,7 @@ To output raw command help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--help|-h` #### `--help|-h`
@ -60,6 +62,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -69,6 +72,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -78,6 +82,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -87,24 +92,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -114,6 +112,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`list` `list`
@ -160,6 +159,7 @@ To output raw command list
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--format` #### `--format`
@ -169,6 +169,7 @@ The output format (txt, xml, json, or md)
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'txt'` * Default: `'txt'`
#### `--help|-h` #### `--help|-h`
@ -178,6 +179,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -187,6 +189,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -196,6 +199,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -205,24 +209,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -232,4 +229,5 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -7,8 +7,7 @@ Console Tool
<info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command <info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command
<info>-q, --quiet</info> Do not output any message <info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version <info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output <info> --ansi|--no-ansi</info> Force (or disable --no-ansi) ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> 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 <info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -46,10 +46,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>
@ -105,10 +105,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>

View File

@ -83,7 +83,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -92,7 +92,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {
@ -186,7 +186,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -195,7 +195,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {
@ -265,7 +265,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -274,7 +274,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {
@ -361,7 +361,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -370,7 +370,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {
@ -438,7 +438,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -447,7 +447,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {
@ -517,7 +517,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Force ANSI output", "description": "Force (or disable --no-ansi) ANSI output",
"default": false "default": false
}, },
"no-ansi": { "no-ansi": {
@ -526,7 +526,7 @@
"accept_value": false, "accept_value": false,
"is_value_required": false, "is_value_required": false,
"is_multiple": false, "is_multiple": false,
"description": "Disable ANSI output", "description": "Negate the \"--ansi\" option",
"default": false "default": false
}, },
"no-interaction": { "no-interaction": {

View File

@ -55,6 +55,7 @@ The output format (txt, xml, json, or md)
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'txt'` * Default: `'txt'`
#### `--raw` #### `--raw`
@ -64,6 +65,7 @@ To output raw command help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--help|-h` #### `--help|-h`
@ -73,6 +75,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -82,6 +85,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -91,6 +95,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -100,24 +105,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -127,6 +125,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`list` `list`
@ -173,6 +172,7 @@ To output raw command list
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--format` #### `--format`
@ -182,6 +182,7 @@ The output format (txt, xml, json, or md)
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'txt'` * Default: `'txt'`
#### `--help|-h` #### `--help|-h`
@ -191,6 +192,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -200,6 +202,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -209,6 +212,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -218,24 +222,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -245,6 +242,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`descriptor:command1` `descriptor:command1`
@ -269,6 +267,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -278,6 +277,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -287,6 +287,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -296,24 +297,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -323,6 +317,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`descriptor:command2` `descriptor:command2`
@ -353,6 +348,7 @@ command 2 help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--help|-h` #### `--help|-h`
@ -362,6 +358,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -371,6 +368,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -380,6 +378,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -389,24 +388,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -416,6 +408,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`descriptor:command4` `descriptor:command4`
@ -437,6 +430,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -446,6 +440,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -455,6 +450,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -464,24 +460,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -491,4 +480,5 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -7,8 +7,7 @@ My Symfony application <info>v1.0</info>
<info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command <info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command
<info>-q, --quiet</info> Do not output any message <info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version <info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output <info> --ansi|--no-ansi</info> Force (or disable --no-ansi) ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> 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 <info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -46,10 +46,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>
@ -105,10 +105,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>
@ -138,10 +138,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>
@ -179,10 +179,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>
@ -210,10 +210,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>
@ -243,10 +243,10 @@
<description>Display this application version</description> <description>Display this application version</description>
</option> </option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description> <description>Force (or disable --no-ansi) ANSI output</description>
</option> </option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description> <description>Negate the "--ansi" option</description>
</option> </option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0"> <option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description> <description>Do not ask any interactive question</description>

View File

@ -7,8 +7,7 @@ My Symfony application <info>v1.0</info>
<info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command <info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command
<info>-q, --quiet</info> Do not output any message <info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version <info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output <info> --ansi|--no-ansi</info> Force (or disable --no-ansi) ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> 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 <info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -46,6 +46,7 @@ The output format (txt, xml, json, or md)
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'txt'` * Default: `'txt'`
#### `--raw` #### `--raw`
@ -55,6 +56,7 @@ To output raw command help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--help|-h` #### `--help|-h`
@ -64,6 +66,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -73,6 +76,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -82,6 +86,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -91,24 +96,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -118,6 +116,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`list` `list`
@ -164,6 +163,7 @@ To output raw command list
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--format` #### `--format`
@ -173,6 +173,7 @@ The output format (txt, xml, json, or md)
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'txt'` * Default: `'txt'`
#### `--help|-h` #### `--help|-h`
@ -182,6 +183,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -191,6 +193,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -200,6 +203,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -209,24 +213,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -236,6 +233,7 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
`descriptor:åèä` `descriptor:åèä`
@ -266,6 +264,7 @@ command åèä help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--help|-h` #### `--help|-h`
@ -275,6 +274,7 @@ Display help for the given command. When no command is given display help for th
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--quiet|-q` #### `--quiet|-q`
@ -284,6 +284,7 @@ Do not output any message
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--verbose|-v|-vv|-vvv` #### `--verbose|-v|-vv|-vvv`
@ -293,6 +294,7 @@ Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--version|-V` #### `--version|-V`
@ -302,24 +304,17 @@ Display this application version
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`
#### `--ansi` #### `--ansi|--no-ansi`
Force ANSI output Force (or disable --no-ansi) ANSI output
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
#### `--no-ansi`
Disable ANSI output
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: yes
* Default: `false` * Default: `false`
#### `--no-interaction|-n` #### `--no-interaction|-n`
@ -329,4 +324,5 @@ Do not ask any interactive question
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -7,8 +7,7 @@ MbString åpplicätion
<info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command <info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command
<info>-q, --quiet</info> Do not output any message <info>-q, --quiet</info> Do not output any message
<info>-V, --version</info> Display this application version <info>-V, --version</info> Display this application version
<info> --ansi</info> Force ANSI output <info> --ansi|--no-ansi</info> Force (or disable --no-ansi) ANSI output
<info> --no-ansi</info> Disable ANSI output
<info>-n, --no-interaction</info> 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 <info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -7,8 +7,7 @@ Options:
-h, --help Display help for the given command. When no command is given display help for the list command -h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message -q, --quiet Do not output any message
-V, --version Display this application version -V, --version Display this application version
--ansi Force ANSI output --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction 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 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -13,8 +13,7 @@ Options:
-h, --help Display help for the given command. When no command is given display help for the list command -h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message -q, --quiet Do not output any message
-V, --version Display this application version -V, --version Display this application version
--ansi Force ANSI output --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction 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 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -13,8 +13,7 @@ Options:
-h, --help Display help for the given command. When no command is given display help for the list command -h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message -q, --quiet Do not output any message
-V, --version Display this application version -V, --version Display this application version
--ansi Force ANSI output --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction 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 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -13,8 +13,7 @@ Options:
-h, --help Display help for the given command. When no command is given display help for the list command -h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message -q, --quiet Do not output any message
-V, --version Display this application version -V, --version Display this application version
--ansi Force ANSI output --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction 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 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

View File

@ -26,4 +26,5 @@ command 2 help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -26,4 +26,5 @@ command åèä help
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -5,4 +5,5 @@
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -13,4 +13,5 @@
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -3,4 +3,5 @@
* Accept value: no * Accept value: no
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `false` * Default: `false`

View File

@ -5,4 +5,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'default_value'` * Default: `'default_value'`

View File

@ -5,4 +5,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `NULL` * Default: `NULL`

View File

@ -5,4 +5,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: no * Is value required: no
* Is multiple: yes * Is multiple: yes
* Is negatable: no
* Default: `array ()` * Default: `array ()`

View File

@ -6,4 +6,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `NULL` * Default: `NULL`

View File

@ -5,4 +5,5 @@ option with multiple shortcuts
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `NULL` * Default: `NULL`

View File

@ -5,4 +5,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: no * Is value required: no
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `INF` * Default: `INF`

View File

@ -5,4 +5,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: no * Is multiple: no
* Is negatable: no
* Default: `'style'` * Default: `'style'`

View File

@ -5,4 +5,5 @@ option description
* Accept value: yes * Accept value: yes
* Is value required: yes * Is value required: yes
* Is multiple: yes * Is multiple: yes
* Is negatable: no
* Default: `array ( 0 => 'Hello', 1 => 'world',)` * Default: `array ( 0 => 'Hello', 1 => 'world',)`

View File

@ -51,6 +51,16 @@ class ArgvInputTest extends TestCase
$this->assertSame($expectedOptions, $input->getOptions(), $message); $this->assertSame($expectedOptions, $input->getOptions(), $message);
} }
/**
* @dataProvider provideNegatableOptions
*/
public function testParseOptionsNegatable($input, $options, $expectedOptions, $message)
{
$input = new ArgvInput($input);
$input->bind(new InputDefinition($options));
$this->assertEquals($expectedOptions, $input->getOptions(), $message);
}
public function provideOptions() public function provideOptions()
{ {
return [ return [
@ -177,6 +187,36 @@ class ArgvInputTest extends TestCase
]; ];
} }
public function provideNegatableOptions()
{
return [
[
['cli.php', '--foo'],
[new InputOption('foo', null, InputOption::VALUE_NEGATABLE)],
['foo' => true],
'->parse() parses long options without a value',
],
[
['cli.php', '--foo'],
[new InputOption('foo', null, InputOption::VALUE_NONE | InputOption::VALUE_NEGATABLE)],
['foo' => true],
'->parse() parses long options without a value',
],
[
['cli.php', '--no-foo'],
[new InputOption('foo', null, InputOption::VALUE_NEGATABLE)],
['foo' => false],
'->parse() parses long options without a value',
],
[
['cli.php', '--no-foo'],
[new InputOption('foo', null, InputOption::VALUE_NONE | InputOption::VALUE_NEGATABLE)],
['foo' => false],
'->parse() parses long options without a value',
],
];
}
/** /**
* @dataProvider provideInvalidInput * @dataProvider provideInvalidInput
*/ */
@ -189,6 +229,18 @@ class ArgvInputTest extends TestCase
$input->bind($definition); $input->bind($definition);
} }
/**
* @dataProvider provideInvalidNegatableInput
*/
public function testInvalidInputNegatable($argv, $definition, $expectedExceptionMessage)
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage($expectedExceptionMessage);
$input = new ArgvInput($argv);
$input->bind($definition);
}
public function provideInvalidInput() public function provideInvalidInput()
{ {
return [ return [
@ -260,6 +312,32 @@ class ArgvInputTest extends TestCase
]; ];
} }
public function provideInvalidNegatableInput()
{
return [
[
['cli.php', '--no-foo=bar'],
new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NEGATABLE)]),
'The "--no-foo" option does not accept a value.',
],
[
['cli.php', '--no-foo='],
new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NEGATABLE)]),
'The "--no-foo" option does not accept a value.',
],
[
['cli.php', '--no-foo=bar'],
new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NONE | InputOption::VALUE_NEGATABLE)]),
'The "--no-foo" option does not accept a value.',
],
[
['cli.php', '--no-foo='],
new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NONE | InputOption::VALUE_NEGATABLE)]),
'The "--no-foo" option does not accept a value.',
],
];
}
public function testParseArrayArgument() public function testParseArrayArgument()
{ {
$input = new ArgvInput(['cli.php', 'foo', 'bar', 'baz', 'bat']); $input = new ArgvInput(['cli.php', 'foo', 'bar', 'baz', 'bat']);

View File

@ -31,6 +31,20 @@ class InputOptionTest extends TestCase
new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY);
} }
public function testBooleanWithRequired()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
new InputOption('foo', 'f', InputOption::VALUE_REQUIRED | InputOption::VALUE_NEGATABLE);
}
public function testBooleanWithOptional()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_NEGATABLE);
}
public function testShortcut() public function testShortcut()
{ {
$option = new InputOption('foo', 'f'); $option = new InputOption('foo', 'f');
@ -150,6 +164,14 @@ class InputOptionTest extends TestCase
$option->setDefault('default'); $option->setDefault('default');
} }
public function testDefaultValueWithValueBooleanMode()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('Cannot set a default value when using InputOption::VALUE_NEGATABLE mode.');
$option = new InputOption('foo', 'f', InputOption::VALUE_NEGATABLE);
$option->setDefault('default');
}
public function testDefaultValueWithIsArrayMode() public function testDefaultValueWithIsArrayMode()
{ {
$this->expectException('LogicException'); $this->expectException('LogicException');

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Input; namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Exception\InvalidOptionException;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputDefinition;

View File

@ -31,7 +31,6 @@ Options:
-h, --help Display help for the given command. When no command is given display help for the %s command -h, --help Display help for the given command. When no command is given display help for the %s command
-q, --quiet Do not output any message -q, --quiet Do not output any message
-V, --version Display this application version -V, --version Display this application version
--ansi Force ANSI output --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction 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 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug