You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
publicmytask() {
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**/publicmytask() {
echo 'I only run on Windows, ugh';
}
protected windows_only(): bool {
return PHP_OS_FAMILY === 'Windows';
}
What are your opinions on that? :)
The text was updated successfully, but these errors were encountered:
saitho
changed the title
Feature request: Disabling commands conditionally
Feature request: Disabling/Hiding commands conditionally
Jan 15, 2021
RyanNerd
added a commit
to RyanNerd/Robo
that referenced
this issue
Jul 4, 2021
If a commands class has a `public string|array $hiddenCommands` property then any command listed in the property will not be added to Robo
Closesconsolidation#1013
Created a PR for this. The condition is set in the constructor by including a public array|string $hiddenCommands property and populating it with commands you don't want to appear in Robo. You can also use the @hidden annotation on any public function you don't want to expose to Robo.
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:
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!):
What are your opinions on that? :)
The text was updated successfully, but these errors were encountered: