8000 [Console] Add option to automatically run suggested command if there is only 1 alternative by pierredup · Pull Request #25732 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Add option to automatically run suggested command if there is only 1 alternative #25732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix CS
  • Loading branch information
pierredup committed Feb 11, 2018
commit d7dc6c778b238cf7c6461d1176692c6a2439b896
3 changes: 1 addition & 2 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\Exception\FatalThrowableError;
Expand Down Expand Up @@ -245,7 +244,7 @@ public function doRun(InputInterface $input, OutputInterface $output)

$style = new SymfonyStyle($input, $output);
$style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
if (!$style->confirm(sprintf("Do you want to run \"%s\" instead? ", $alternative), false)) {
if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
if (null !== $this->dispatcher) {
$event = new ConsoleErrorEvent($input, $output, $e);
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,15 @@ public function testDontRunAlternativeNamespaceName()
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foos:bar1'), array('decorated' => false));
$this->assertSame("
$this->assertSame('

There are no commands defined in the \"foos\" namespace.
There are no commands defined in the "foos" namespace.

Did you mean this?
foo


", $tester->getDisplay(true));
', $tester->getDisplay(true));
}

public function testCanRunAlternativeCommandName()
Expand Down
0