Skip to content

Commit

Permalink
feature #20867 [Console] Include application name/version in JSON des…
Browse files Browse the repository at this point in the history
…criptions (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
  • Loading branch information
fabpot committed Dec 13, 2016
2 parents 462a02b + a43e040 commit 7e657b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
Expand Up @@ -71,9 +71,21 @@ protected function describeApplication(Application $application, array $options
$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);
}
Expand Down
@@ -1,4 +1,8 @@
{
"application": {
"name": "My Symfony application",
"version": "v1.0"
},
"commands": [
{
"name": "help",
Expand Down

0 comments on commit 7e657b8

Please sign in to comment.