Skip to content
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

Add method to register commands from extensions #66

Merged
Merged
Changes from all commits
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
13 changes: 13 additions & 0 deletions src/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
use PHPUnuhi\Commands\ValidateSpellingCommand;
use PHPUnuhi\Commands\ValidateStructureCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;

class AppManager
{
/** @var array<Command> $extensionCommands */
private static array $extensionCommands = [];

/**
* @throws Exception
*/
Expand Down Expand Up @@ -61,8 +65,17 @@ public static function run(): void

$application->add(new FixSpellingCommand());

foreach (self::$extensionCommands as $command) {
$application->add($command);
}

$application->setDefaultCommand('list');

$application->run();
}

public static function registerExtensionCommand(Command $command): void
{
self::$extensionCommands[$command->getName()] = $command;
}
}
Loading