Skip to content

Commit de29766

Browse files
committed
Allow default command
1 parent 27f2f4d commit de29766

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/guides-cli/src/Application.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
use Symfony\Component\Console\Application as BaseApplication;
1717
use Symfony\Component\Console\Command\Command;
1818
use Symfony\Component\Console\Input\InputDefinition;
19+
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Input\InputOption;
2021

2122
use function count;
2223
use function getcwd;
2324
use function is_array;
25+
use function is_string;
2426
use function iterator_to_array;
2527

2628
final class Application extends BaseApplication
@@ -63,4 +65,22 @@ protected function getDefaultInputDefinition(): InputDefinition
6365

6466
return $definition;
6567
}
68+
69+
protected function getCommandName(InputInterface $input): string|null
70+
{
71+
if ($input->hasArgument('command') === false) {
72+
return parent::getCommandName($input);
73+
}
74+
75+
$command = $input->getArgument('command');
76+
if ($command === null) {
77+
return 'run';
78+
}
79+
80+
if (is_string($command)) {
81+
return $command;
82+
}
83+
84+
return null;
85+
}
6686
}

0 commit comments

Comments
 (0)