Open
Description
Hi there,
I'd like to disable commands conditionally (e.g. when the system environment is not fulfilled).
Obviously I could just check the command and abort it if conditions are not met.
However I'd like those commands to not even show up in the command list.
This could work like this:
public mytask() {
echo 'I only run on Windows, ugh';
}
protected mytask__enabled(): bool {
return PHP_OS_FAMILY === 'Windows';
}
So when collecting the commands, Robo would check for a [commandname]__enabled
method.
If it exists and returns false
, the command will be ignored.
The naming could be made more dynamic by using annotations (but would also mean some performance cost!):
/**
* @enabled windows_only
**/
public mytask() {
echo 'I only run on Windows, ugh';
}
protected windows_only(): bool {
return PHP_OS_FAMILY === 'Windows';
}
What are your opinions on that? :)
Metadata
Metadata
Assignees
Labels
No labels