drush icon indicating copy to clipboard operation
drush copied to clipboard

Shell aliases (or yml commands)

Open greg-1-anderson opened this issue 8 years ago • 13 comments

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.

greg-1-anderson avatar Sep 18 '17 23:09 greg-1-anderson

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.

weitzman avatar Sep 19 '17 00:09 weitzman

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?

greg-1-anderson avatar Sep 19 '17 00:09 greg-1-anderson

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

weitzman avatar Oct 01 '17 15:10 weitzman

Here is drush9 equivalent of config-list drush config-status --operation=all --format=list

weitzman avatar Oct 09 '17 15:10 weitzman

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.

johnpitcairn avatar Mar 13 '18 01:03 johnpitcairn

No update unfortunately. Its an open feature request. I suggest using bash aliases and drush commands/scripts to transition from drush shell aliases.

weitzman avatar Mar 13 '18 01:03 weitzman

You could also consider using a similar service such as ahoy-cli

greg-1-anderson avatar Mar 13 '18 01:03 greg-1-anderson

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?

johnpitcairn avatar Jun 17 '18 02:06 johnpitcairn

The status here is "PRs welcome". Someone just needs to feel it is important enough to spend the effort.

greg-1-anderson avatar Jun 17 '18 03:06 greg-1-anderson

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 avatar Aug 19 '18 16:08 generalredneck

@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.

greg-1-anderson avatar Aug 19 '18 17:08 greg-1-anderson

Also, I've used Ahoy for yaml aliases

weitzman avatar Aug 21 '18 01:08 weitzman

Not a burning need for this.

weitzman avatar Nov 26 '18 23:11 weitzman