Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[console] Use your Drush @aliases to call Drupal Console #1104

Closed
greg-1-anderson opened this issue Oct 25, 2015 · 5 comments
Closed

[console] Use your Drush @aliases to call Drupal Console #1104

greg-1-anderson opened this issue Oct 25, 2015 · 5 comments

Comments

@greg-1-anderson
Copy link
Contributor

If you source something like the script below in a .bashrc or .bash_profile, then you can use drupal @drushalias console:command to run Drupal Console commands using Drush aliases. Also works for remote site aliases.

#!/bin/bash

#
# Cool bash functions to integrate Drupal Console with Drush remote alias execution
#

# Allow `drupal @site consolecommand` as a shortcut for `cd @site; drupal consolecommand`.
# Also works on remote sites, though.
function drupal() {
  s="$1"
  if [ -n "$s" ] && [ ${s:0:1} == "@" ]
  then
    d="$(drush drupal-directory $s 2>/dev/null)"
    rh="$(drush sa ${s%%:*} --fields=remote-host --format=list)"
    if [ -n "$rh" ]
    then
      drush ${s%%:*} ssh "console '$d' ; git ${@:2}"
    else
      echo cd "$d" \; drupal "${@:2}"
      (
        cd "$d"
        "$(which drupal)" "${@:2}"
      )
    fi
  else
    "$(which drupal)" "$@"
  fi
}
@jmolivas jmolivas changed the title Use your Drush @aliases to call Drupal Console [console] Use your Drush @aliases to call Drupal Console Oct 29, 2015
@itsdarrylnorris
Copy link
Contributor

This issue does not longer apply because Drush is not part of Drupal Console anymore (#1520). For this reason I'm closing this issue.

@greg-1-anderson
Copy link
Contributor Author

The script here does not depend on the function removed in #1520. Closing is fine, though; this example does not need to be part of Drupal Console; it would work for folks who want to use it independent of whether or not it is distributed as part of this project.

@jmolivas
Copy link
Member

As mentioned by @greg-1-anderson this is not related to #1520, this is to take advantage of a common way of using aliases a la drush I will leave this open and test it to see how can we take advanatge of.

@jmolivas jmolivas reopened this Jan 16, 2016
@itsdarrylnorris
Copy link
Contributor

Using this code as inspiration, we have merge this functionality into DrupalConsole core. You can use either --target or @.

Here is the implementation - https://github.com/hechoendrupal/DrupalConsole/blob/master/src/Application.php#L115

@greg-1-anderson
Copy link
Contributor Author

Very nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants