@@ -135,14 +135,41 @@ protected function describeInputDefinition(InputDefinition $definition, array $o
135
135
*/
136
136
protected function describeCommand (Command $ command , array $ options = array ())
137
137
{
138
+ $ namespace = substr (
139
+ $ command ->getName (),
140
+ 0 ,
141
+ (strpos ($ command ->getName (), ': ' )?:0 )
142
+ );
143
+ $ commandData = $ command ->getApplication ()->getData ();
144
+ $ commands = $ commandData ['commands ' ][$ namespace ];
145
+ $ examples = [];
146
+ foreach ($ commands as $ item ) {
147
+ if ($ item ['name ' ] == $ command ->getName ()) {
148
+ $ examples = $ item ['examples ' ];
149
+ break ;
150
+ }
151
+ }
152
+
138
153
$ command ->getSynopsis (true );
139
154
$ command ->getSynopsis (false );
140
155
$ command ->mergeApplicationDefinition (false );
141
156
$ this ->writeText ($ command ->trans ('commands.list.messages.usage ' ), $ options );
142
157
foreach (array_merge (array ($ command ->getSynopsis (true )), $ command ->getAliases (), $ command ->getUsages ()) as $ usage ) {
143
- $ this ->writeText ("\n" );
144
158
$ this ->writeText (' ' .$ usage , $ options );
159
+ $ this ->writeText ("\n" );
145
160
}
161
+ if ($ examples ) {
162
+ $ this ->writeText ("\n" );
163
+ $ this ->writeText ("<comment>Examples:</comment> " , $ options );
164
+ foreach ($ examples as $ example ) {
165
+ $ this ->writeText ("\n" );
166
+ $ this ->writeText (' ' .$ example ['description ' ]);
167
+ $ this ->writeText ("\n" );
168
+ $ this ->writeText (' ' .$ example ['execution ' ]);
169
+ $ this ->writeText ("\n" );
170
+ }
171
+ }
172
+
146
173
$ this ->writeText ("\n" );
147
174
$ definition = $ command ->getNativeDefinition ();
148
175
if ($ definition ->getOptions () || $ definition ->getArguments ()) {
0 commit comments