Skip to content

Commit ee05e91

Browse files
authored
[generate:site:alias] Add site option flag. (#336)
1 parent ca73336 commit ee05e91

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Command/Generate/SiteAliasCommand.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ protected function configure()
7777
$this->trans('commands.generate.site.alias.description')
7878
)
7979
->setHelp($this->trans('commands.generate.site.alias.help'))
80+
->addOption(
81+
'site',
82+
null,
83+
InputOption::VALUE_NONE,
84+
$this->trans('commands.generate.site.alias.options.site')
85+
)
8086
->addOption(
8187
'name',
8288
null,
@@ -147,6 +153,7 @@ protected function interact(
147153
InputInterface $input,
148154
OutputInterface $output
149155
) {
156+
$site = $input->getOption('site');
150157
$name = $input->getOption('name');
151158
if (!$name) {
152159
$sites = $this->configurationManager->getSites();
@@ -269,6 +276,10 @@ protected function interact(
269276
}
270277

271278
$directory = $input->getOption('directory');
279+
if ($site && $this->drupalFinder->getComposerRoot()) {
280+
$directory = $this->drupalFinder->getComposerRoot() . '/console/';
281+
}
282+
272283
if (!$directory) {
273284
$directory = $this->getIo()->choice(
274285
$this->trans('commands.generate.site.alias.questions.directory'),
@@ -286,6 +297,11 @@ protected function execute(
286297
InputInterface $input,
287298
OutputInterface $output
288299
) {
300+
$site = $input->getOption('site');
301+
$directory = $input->getOption('directory');
302+
if ($site && $this->drupalFinder->isValidDrupal()) {
303+
$directory = $this->drupalFinder->getComposerRoot() . '/console/';
304+
}
289305
$this->generator->generate(
290306
[
291307
'name' => $input->getOption('name'),
@@ -297,7 +313,7 @@ protected function execute(
297313
'port' => $input->getOption('port'),
298314
'user' => $input->getOption('user'),
299315
'host' => $input->getOption('host'),
300-
'directory' => $input->getOption('directory')
316+
'directory' => $directory
301317
]
302318
);
303319
}

0 commit comments

Comments
 (0)