2 namespace Drush\Commands;
4 use Consolidation\AnnotatedCommand\AnnotationData;
5 use Consolidation\SiteAlias\SiteAliasManagerAwareInterface;
6 use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
7 use Symfony\Component\Console\Input\InputInterface;
10 * Load this example by using the --include option - e.g. `drush --include=/path/to/drush/examples`
12 class SiteAliasAlterCommands extends DrushCommands implements SiteAliasManagerAwareInterface
15 use SiteAliasManagerAwareTrait;
18 * A few example alterations to site aliases.
22 * @param \Symfony\Component\Console\Input\InputInterface $input
23 * @param \Consolidation\AnnotatedCommand\AnnotationData $annotationData
25 public function alter(InputInterface $input, AnnotationData $annotationData)
27 $self = $this->siteAliasManager()->getSelf();
28 if ($self->isRemote()) {
29 // Always pass along ssh keys.
30 if (!$self->has('ssh.options')) {
31 // Don't edit the alias - edit the general config service instead.
32 $this->getConfig()->set('ssh.options', '-o ForwardAgent=yes');
35 // Change the SSH user.
36 $input->setOption('remote-user', 'mw2');