Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a43e040

Browse files
committed
[Console] Include application name/version in JSON descriptions
1 parent 51bc35c commit a43e040

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Symfony/Component/Console/Descriptor/JsonDescriptor.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,21 @@ protected function describeApplication(Application $application, array $options
7171
$commands[] = $this->getCommandData($command);
7272
}
7373

74-
$data = $describedNamespace
75-
? array('commands' => $commands, 'namespace' => $describedNamespace)
76-
: array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
74+
$data = array();
75+
if ('UNKNOWN' !== $application->getName()) {
76+
$data['application']['name'] = $application->getName();
77+
if ('UNKNOWN' !== $application->getVersion()) {
78+
$data['application']['version'] = $application->getVersion();
79+
}
80+
}
81+
82+
$data['commands'] = $commands;
83+
84+
if ($describedNamespace) {
85+
$data['namespace'] = $describedNamespace;
86+
} else {
87+
$data['namespaces'] = array_values($description->getNamespaces());
88+
}
7789

7890
$this->writeData($data, $options);
7991
}

src/Symfony/Component/Console/Tests/Fixtures/application_2.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"application": {
3+
"name": "My Symfony application",
4+
"version": "v1.0"
5+
},
26
"commands": [
37
{
48
"name": "help",

0 commit comments

Comments
 (0)