I would like to detect from code the current running drush command. I have some hooks that will be run when I exec some drush commands and want to detect which command is triggering the hook.
I manage to get the info from input() but I want to know if there is a more appropriate way:
if (PHP_SAPI === 'cli') {
$command = \Drush\Drush::input()->getArguments()
}
I would like to have something similar to this:
if (PHP_SAPI === 'cli') {
$command = \Drush\Drush::...getCurentCommand();
}
Similar to Drupal::routeMatch()->getRouteName() in someway.
Thank you