Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from phel-lang/refactor/create-command-facade
Create CommandFacade and use it as entry point instead of CommandFactory
- Loading branch information
Showing
7 changed files
with
87 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
$slash = DIRECTORY_SEPARATOR; | ||
declare(strict_types=1); | ||
|
||
use Phel\Command\CommandFactory; | ||
use Phel\Command\CommandFacade; | ||
use Symfony\Component\Console\Application; | ||
|
||
$projectRootDir = getcwd() . $slash; | ||
$autoloadPath = $projectRootDir . 'vendor' . $slash . 'autoload.php'; | ||
$projectRootDir = getcwd() . DIRECTORY_SEPARATOR; | ||
$autoloadPath = $projectRootDir . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; | ||
|
||
if (!file_exists($autoloadPath)) { | ||
exit("Cannot load composer's autoload file: " . $autoloadPath); | ||
exit("Cannot load composer's autoload file: $autoloadPath\n"); | ||
} | ||
|
||
require $autoloadPath; | ||
|
||
$commandFactory = new CommandFactory(); | ||
$commandFacade = new CommandFacade(); | ||
|
||
$application = new Application(); | ||
$application->add($commandFactory->createExportCommand()); | ||
$application->add($commandFactory->createFormatCommand()); | ||
$application->add($commandFactory->createReplCommand()); | ||
$application->add($commandFactory->createRunCommand()); | ||
$application->add($commandFactory->createTestCommand()); | ||
$application->add($commandFacade->getExportCommand()); | ||
$application->add($commandFacade->getFormatCommand()); | ||
$application->add($commandFacade->getReplCommand()); | ||
$application->add($commandFacade->getRunCommand()); | ||
$application->add($commandFacade->getTestCommand()); | ||
$application->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phel\Command; | ||
|
||
use Gacela\Framework\AbstractFacade; | ||
use Phel\Command\Export\ExportCommand; | ||
use Phel\Command\Format\FormatCommand; | ||
use Phel\Command\Repl\ReplCommand; | ||
use Phel\Command\Run\RunCommand; | ||
use Phel\Command\Test\TestCommand; | ||
|
||
/** | ||
* @method CommandFactory getFactory() | ||
*/ | ||
final class CommandFacade extends AbstractFacade | ||
{ | ||
public function getReplCommand(): ReplCommand | ||
{ | ||
return $this->getFactory()->createReplCommand(); | ||
} | ||
|
||
public function getRunCommand(): RunCommand | ||
{ | ||
return $this->getFactory()->createRunCommand(); | ||
} | ||
|
||
public function getTestCommand(): TestCommand | ||
{ | ||
return $this->getFactory()->createTestCommand(); | ||
} | ||
|
||
public function getFormatCommand(): FormatCommand | ||
{ | ||
return $this->getFactory()->createFormatCommand(); | ||
} | ||
|
||
public function getExportCommand(): ExportCommand | ||
{ | ||
return $this->getFactory()->createExportCommand(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters