@@ -198,6 +198,8 @@ protected function describeApplication(Application $application, array $options
198
198
$ commands [$ name ] = $ description ->getCommand ($ name );
199
199
}
200
200
}
201
+
202
+ // calculate max. width based on available commands per namespace
201
203
$ width = $ this ->getColumnWidth (call_user_func_array ('array_merge ' , array_map (function ($ namespace ) use ($ commands ) {
202
204
return array_intersect ($ namespace ['commands ' ], array_keys ($ commands ));
203
205
}, $ namespaces )));
@@ -209,19 +211,25 @@ protected function describeApplication(Application $application, array $options
209
211
}
210
212
211
213
foreach ($ namespaces as $ namespace ) {
212
- if (!$ describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $ namespace ['id ' ] && array_intersect ($ namespace ['commands ' ], array_keys ($ commands ))) {
214
+ $ namespace ['commands ' ] = array_filter ($ namespace ['commands ' ], function ($ name ) use ($ commands ) {
215
+ return isset ($ commands [$ name ]);
216
+ });
217
+
218
+ if (!$ namespace ['commands ' ]) {
219
+ continue ;
220
+ }
221
+
222
+ if (!$ describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $ namespace ['id ' ]) {
213
223
$ this ->writeText ("\n" );
214
224
$ this ->writeText (' <comment> ' .$ namespace ['id ' ].'</comment> ' , $ options );
215
225
}
216
226
217
227
foreach ($ namespace ['commands ' ] as $ name ) {
218
- if (isset ($ commands [$ name ])) {
219
- $ this ->writeText ("\n" );
220
- $ spacingWidth = $ width - strlen ($ name );
221
- $ command = $ commands [$ name ];
222
- $ commandAliases = $ name === $ command ->getName () ? $ this ->getCommandAliasesText ($ command ) : '' ;
223
- $ this ->writeText (sprintf (' <info>%s</info>%s%s ' , $ name , str_repeat (' ' , $ spacingWidth ), $ commandAliases .$ command ->getDescription ()), $ options );
224
- }
228
+ $ this ->writeText ("\n" );
229
+ $ spacingWidth = $ width - strlen ($ name );
230
+ $ command = $ commands [$ name ];
231
+ $ commandAliases = $ name === $ command ->getName () ? $ this ->getCommandAliasesText ($ command ) : '' ;
232
+ $ this ->writeText (sprintf (' <info>%s</info>%s%s ' , $ name , str_repeat (' ' , $ spacingWidth ), $ commandAliases .$ command ->getDescription ()), $ options );
225
233
}
226
234
}
227
235
0 commit comments