Skip to content

Commit

Permalink
[Console] Include application name/version in JSON descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed Dec 11, 2016
1 parent 51bc35c commit a43e040
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 a43e040

Please sign in to comment.