Skip to content

Commit

Permalink
Sort the list of aliases alphabetically
Browse files Browse the repository at this point in the history
This will make it easier to find a specific alias in the list, and groups
related aliases together.

Fixes #408.
  • Loading branch information
nicwortel authored and theseer committed Jun 15, 2023
1 parent dfba120 commit 22e35df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/commands/list/ListCommand.php
Expand Up @@ -11,6 +11,7 @@
namespace PharIo\Phive;

use function count;
use function sort;

class ListCommand implements Cli\Command {
/** @var SourcesList */
Expand Down Expand Up @@ -41,6 +42,8 @@ public function execute(): void {
}

private function printAliases(array $aliases): void {
sort($aliases);

foreach ($aliases as $aliasName) {
$this->output->writeText("* {$aliasName}\n");
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/commands/list/ListCommandTest.php
Expand Up @@ -35,15 +35,15 @@ public function testWritesExpectedAliasesToOutput(): void {

$output->expects($this->at(3))
->method('writeText')
->with($this->stringContains('phpunit'));
->with($this->stringContains('phpab'));

$output->expects($this->at(4))
->method('writeText')
->with($this->stringContains('phpab'));
->with($this->stringContains('phploc'));

$output->expects($this->at(5))
->method('writeText')
->with($this->stringContains('phploc'));
->with($this->stringContains('phpunit'));

$command = new ListCommand($sourcesList, $localSources, $output);
$command->execute();
Expand Down

0 comments on commit 22e35df

Please sign in to comment.