How to overridden command via hook_drush_command_alter? I'd like to override command using hook_drush_command_alter before run as below:

/**   
 * Implementation of hook_drush_command_alter().
 */
function policy_drush_command_alter(&amp;$command) {
  if ($command['command'] == 'features-revert-all') {
    $command['command'] = 'custom-features-revert-all';
    $command['command-hook'] = 'custom-features-revert-all';
  }
}   


However it doesn't work (it's calling the old command). I'm doing it right? Is it possible using this hook?
The command_alter hook is not super friendly / obvious when it comes to complete command replacement, as this hook was only designed to make minor alterations to the command.  It is all the same possible to replace one command with another, but the process is a bit obtuse, as you need to reset some variables that Drush has already initialized.

This should do the trick:

/**
 * Implements hook_drush_command_alter
 */
function policy_drush_command_alter(&amp;$command) {
  if (($command['command'] == 'features-revert-all') &amp;&amp; (drush_drupal_major_version() &gt;= 8)) {
    $command['command'] = 'custom-features-revert-all';
    $command['command-hook'] = 'custom-features-revert-all';
    $command['primary function'] = FALSE;
    $command['arguments'] = array(); // Adjust this only as needed
    drush_set_command($command);
  }
}


Note that this example removes any arguments the user may have passed to the command; I included this just to demonstrate how to alter the arguments, in case this is needed. Remove the assignment to $command['arguments'] if you'd like the original args passed through.