drush
drush copied to clipboard
Shell aliases (or yml commands)
We should follow the lead of Travis CI and Circle CI & c. and put simple shell scripts in our yml configuration files:
shell:
-
command: hello
option: who
default: who World
script:
- echo "Hello, $WHO"
-
command: knock:knock
script:
- echo "Who's there?"
Environment variables are automatically set for each defined option and argument.
We could potentially have a shortcut for Drush commands, but I'm not sure that it is necessary.
Look good to me, as long as we don't need much custom code to process the yaml file and execute the script. Perhaps there is code we can bring in.
Or maybe:
shell:
-
command: hello
options
who: World
count: 1
option-descriptions:
who: Who to say hello to
count: How many times to say hello
script:
- seq $COUNT | xargs -Iz echo "Hello, $WHO"
The question is, is either of these forms significantly simpler than a php commandfile to make this worthwhile?
If we are going for a straight replacement, the existing logic is at https://github.com/drush-ops/drush/blob/fd5b1c7d65947ad3b580cf22d765f2487a8f4e32/includes/command.inc#L1930-L1996
Here is drush9 equivalent of config-list drush config-status --operation=all --format=list
What is the current status of this? I'm currently pegged at drush 9.0-beta4, which appears to be the last version that supports old-style drushrc.php shell command aliases.
I'm very conscious that is not an ideal situation, but I depend fairly heavily on some custom pull-production (etc) shell aliases for my current workflow.
No update unfortunately. Its an open feature request. I suggest using bash aliases and drush commands/scripts to transition from drush shell aliases.
You could also consider using a similar service such as ahoy-cli
Thanks @greg-1-anderson . I looked at Ahoy but at present I'm all about reducing lateral dependencies, so anything that needs a custom install per platform is really a no-go. Ideally Drush would continue to handle this via an optional composer dependency. I don't especially care whether I would need to rewrite the existing PHP script definitions as YML, I'd just like to be able to do so.
@weitzman : Yeah. But then everyone is back to rolling their own solution in bash or cli-php or whatever, and isn't that what Drush was designed to avoid for the slightly savvy site builder?
The status here is "PRs welcome". Someone just needs to feel it is important enough to spend the effort.
So instead of shell aliases... the current workaround is to go ahead and write a custom command that calls the shell correct?
The reason I ask is because I rely on drush shell aliases because they are typically supported on hosting environments where calling shell via ssh or other means are not... example I can do something like drush deploy and it's something like drush updb; drush cim -y; drush cr; all in one for D8 and drush rr; drush updb -y; drush cc all; drush fra -y; drush cc all; for D7... and it's consistent so that anyone deploying only has to know the 1 command.
@generalredneck I use composer scripts for that purpose. Writing simple Drush commands in php is another option.
If someone did want to make a PR for this, perhaps it should be a feature of Robo / consolidation/config.
Also, I've used Ahoy for yaml aliases
Not a burning need for this.