This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces CLI main class; Renames InitCommand
- Loading branch information
1 parent
043db72
commit 24d6698
Showing
2 changed files
with
74 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Tonik\Gin\Foundation\Console; | ||
|
||
use Symfony\Component\Console\Application; | ||
|
||
class CLI | ||
{ | ||
/** | ||
* Console application instance. | ||
* | ||
* @var \Symfony\Component\Console\Application | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* List of commands to register. | ||
* | ||
* @var array | ||
*/ | ||
protected $commands = [ | ||
'Tonik\Gin\Foundation\Console\Command\ShakeCommand' | ||
]; | ||
|
||
/** | ||
* Console application banner. | ||
* | ||
* @var string | ||
*/ | ||
private $banner = ' | ||
___ __ / __ | ||
| / \ |\ | | |__/ / / _` | |\ | | ||
| \__/ | \| | | \ / \__| | | \| | ||
/ | ||
'; | ||
|
||
/** | ||
* Construct CLI. | ||
*/ | ||
function __construct() | ||
{ | ||
$this->app = new Application($this->banner); | ||
|
||
$this->bootstrap(); | ||
} | ||
|
||
/** | ||
* Boodstraps CLI. | ||
* | ||
* @return void | ||
*/ | ||
protected function bootstrap() | ||
{ | ||
$this->addCommands($this->commands); | ||
|
||
$this->app->run(); | ||
} | ||
|
||
/** | ||
* Registers commands within console application. | ||
* | ||
* @param array $commands | ||
*/ | ||
protected function addCommands(array $commands) | ||
{ | ||
foreach ($commands as $command) { | ||
$this->app->add(new $command); | ||
} | ||
} | ||
} |
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