I'm aware of validate
/pre
/post
COMMAND hooks and I would like to replace the logic of the existing drush command on specific condition using policy commandfile with something else, e.g.
/**
* Implementation of drush_hook_COMMAND_validate().
*
* Validate feature revert of specific module.
*/
function drush_policy_features_revert_validate() {
if (strpos($args[1], 'rules') !== FALSE) {
drush_invoke_process('@self', 'rules-revert-all');
drush_print('Rules reverted in custom way!');
return drush_set_error('POLICY_DENY', dt('Rules features already reverted.'));
}
}
However the problem is when I return TRUE
- the command which I want to override is called after than, on the other hand when I'm returning FALSE
, the drush
will fail with non-zero exit code which could cause some other issues (like breaking the deployment).
Is there any better way of overriding the logic of existing drush command without described side-effects? Secondly validation hook doesn't sound right to implement that kind of logic.