Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace Drush\Commands; | ||
|
||
use Consolidation\AnnotatedCommand\AnnotationData; | ||
use Drush\SiteAlias\SiteAliasManagerAwareInterface; | ||
use Drush\SiteAlias\SiteAliasManagerAwareTrait; | ||
use Robo\Common\ConfigAwareTrait; | ||
use Robo\Contract\ConfigAwareInterface; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
/** | ||
* Load this example by using the --include option - e.g. `drush --include=/path/to/drush/examples` | ||
*/ | ||
class SiteAliasAlterCommands extends DrushCommands implements SiteAliasManagerAwareInterface, ConfigAwareInterface { | ||
|
||
use SiteAliasManagerAwareTrait; | ||
use ConfigAwareTrait; | ||
|
||
/** | ||
* A few example alterations to site aliases. | ||
* | ||
* @hook pre-init * | ||
* | ||
* @param \Symfony\Component\Console\Input\InputInterface $input | ||
* @param \Consolidation\AnnotatedCommand\AnnotationData $annotationData | ||
*/ | ||
public function alter(InputInterface $input, AnnotationData $annotationData) { | ||
$self = $this->siteAliasManager()->getSelf(); | ||
if ($self->isRemote()) { | ||
|
||
// Always pass along ssh keys. | ||
if (!$self->has('ssh.options')) { | ||
// Don't edit the alias - edit the general config service instead. | ||
$this->getConfig()->set('ssh.options', '-o ForwardAgent=yes'); | ||
} | ||
|
||
// Change the SSH user. | ||
$input->setOption('remote-user', 'mw2'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters