Posted by kgaut on July 10, 2012 at 11:49am
Hi,
I'm trying to write my own drush command, and I want to get the drush alias used within the command.
for example if the user type :
drush @mysite mycommand option
in drush_mycommand, how to get "@mysite" ?
Thanks.
Comments
An example is at
An example is at http://api.drush.ws/api/drush/commands!core!ssh.drush.inc/function/drush_ssh_site_ssh/5.x,
$alias = drush_get_context('DRUSH_TARGET_SITE_ALIAS');$site = drush_sitealias_get_record($alias);
thanks a lot, $alias =
thanks a lot,
$alias = drush_get_context('DRUSH_TARGET_SITE_ALIAS');this is what I needed!
cheers
I should add that this is
I should add that this is only available in the local call. Once the call has redispatched to remote site alias, you lose the original alias. In order to avoid that redispatch, declare your command with
'handle-remote-commands' => TRUE,. Again, seesshcommand.