Implemented Sort and group list of CLI commands

Sim

Well-known member
Rather than an incredibly long list of randomly sorted commands, please display them like Laravel and group them by prefix (xf / xf-dev / etc) and sort them alphabetically

1596760878946.webp
 
Upvote 6
This suggestion has been implemented. Votes are no longer accepted.
Laravel does use Symfony components, but so does XF -- our console stuff comes from Symfony console. Though note that due to our PHP requirements, we use an older set of components (currently 3.4).

However. if you run list it does give you a namespace-grouped list of commands. It looks pretty much exactly like the screenshot. If you pass in nothing it doesn't as that's coming from it's "recommend the command I may have meant" code path (from Symfony). I'm unsure if that's the usual behavior or related to our code.

But overall, I think this suggestion is already there.
 
I think there is an element of this which appears to be related to our command runner logic.

In the general Symfony Console case you just call $console->run($input, $output) and there's not much more to do.

However, we have mechanisms like changing the App type or, in 2.2, detecting if add-on commands are runnable. To do that we do a few steps before running which involves first calling $console->find($name) and this throws a CommandNotFound exception if no command name or an empty string is passed in.

To workaround this I've just changed this:
PHP:
$name = $input->getFirstArgument();

To this:
PHP:
$name = $input->getFirstArgument() ?: 'list';

Now php cmd.php is the same as calling php cmd.php list which matches the same behaviour as Symfony and Laravel by default.
 
Back
Top Bottom