Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a43e040

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

File tree

Expand file treeCollapse file tree

2 files changed

+19
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
+15-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Fixtures/application_2.json
+4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.