Open greg-1-anderson opened 6 years ago
Mostly resolved by #3116
Thats now merged. We now give a helpful error message in this situation but these commands are absent from help so I'll leave this open.
Symfony 3.4 brought us lazy loaded commands - perhaps that makes this easier? Lazy loaded commands would speed up Drush a bit as well.
I don't know that we need that; what we want is just a command that has the right metadata but does nothing. So, if you run Drush in a situation where a Drupal site cannot bootstrap, it could still take all of the annotation data from the Drupal/Commands and instantiate proxy commands so that "help" and "list" will work. If we also want this to work with module extensions, then we'd need a fast way to discover those extensions without bootstrapping. Drush 8 and earlier used to do this (still do this) for the 'list' and 'help' commands.
Lazy loaded commands allow proxy commands that also can do something if they are executed; we just want to print a message, so we can probably just make a regular Symfony Console command (or maybe a regular AnnotatedCommand).
In instances where we can bootstrap a Drupal site, we do bootstrap it in order to load its extension commands. We typically don't have heavyweight operations that need to be done before a command executes other than bootstrapping, so I'm not sure there are many places where lazy-loading would speed up Drush.
It is very confusing to folks that commands such as
pm:enable
are invisible unless we have bootstrapped a Drupal site. While we cannot instantiate these commandfiles without a working Drupal 8 site due to their use of dependency injection, it would be possible to instead instantiate proxy commands for them, so that users could see which commands were available, and see a useful diagnostic message about bootstrapping if an unavailable command is executed.