feature #20867 [Console] Include application name/version in JSON descriptions (ro0NL)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Console] Include application name/version in JSON descriptions

| Q             | A
| ------------- | ---
| Branch?       | "master"
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any
| License       | MIT
| Doc PR        | reference to the documentation PR, if any

To be consistent with other formats.

Commits
-------

a43e040 [Console] Include application name/version in JSON descriptions
This commit is contained in:
Fabien Potencier 2016-12-13 09:27:32 +01:00
commit 7e657b8b01
2 changed files with 19 additions and 3 deletions

View File

@ -71,9 +71,21 @@ class JsonDescriptor extends Descriptor
$commands[] = $this->getCommandData($command);
}
$data = $describedNamespace
? array('commands' => $commands, 'namespace' => $describedNamespace)
: array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
$data = array();
if ('UNKNOWN' !== $application->getName()) {
$data['application']['name'] = $application->getName();
if ('UNKNOWN' !== $application->getVersion()) {
$data['application']['version'] = $application->getVersion();
}
}
$data['commands'] = $commands;
if ($describedNamespace) {
$data['namespace'] = $describedNamespace;
} else {
$data['namespaces'] = array_values($description->getNamespaces());
}
$this->writeData($data, $options);
}

View File

@ -1,4 +1,8 @@
{
"application": {
"name": "My Symfony application",
"version": "v1.0"
},
"commands": [
{
"name": "help",