Skip to content
Permalink
Browse files

Output the command list when no command is given.

Make `bin/cake` in CommandRunner work similar to how it works with
ShellDispatcher. Output the help list when no command is given.
  • Loading branch information...
markstory committed Jul 28, 2017
1 parent 0a5bf84 commit 3f08be54fb23941c2bafcaadda6e623eb3905e35
Showing with 27 additions and 0 deletions.
  1. +4 −0 src/Console/CommandRunner.php
  2. +23 −0 tests/TestCase/Console/CommandRunnerTest.php
@@ -162,6 +162,10 @@ public function run(array $argv, ConsoleIo $io = null)
*/
protected function getShell(ConsoleIo $io, CommandCollection $commands, $name)
{
if (!$name) {
$io->err('<error>No command provided. Choose one of the available commands.</error>', 2);
$name = 'help';
}
if (isset($this->aliases[$name])) {
$name = $this->aliases[$name];
}
@@ -145,6 +145,29 @@ public function testRunHelpShortOption()
$this->assertContains('Available Commands', $messages);
}
/**
* Test that no command outputs the command list
*
* @return void
*/
public function testRunNoCommand()
{
$app = $this->getMockBuilder(BaseApplication::class)
->setMethods(['middleware', 'bootstrap'])
->setConstructorArgs([$this->config])
->getMock();
$output = new ConsoleOutput();
$runner = new CommandRunner($app);
$result = $runner->run(['cake'], $this->getMockIo($output));
$this->assertSame(0, $result, 'help output is success.');
$messages = implode("\n", $output->messages());
$this->assertContains('No command provided. Choose one of the available commands', $messages);
$this->assertContains('- i18n', $messages);
$this->assertContains('Available Commands', $messages);
}
/**
* Test using `cake --verson` invokes the version command
*

0 comments on commit 3f08be5

Please sign in to comment.
You can’t perform that action at this time.