Skip to content

Commit

Permalink
register and load build in commands
Browse files Browse the repository at this point in the history
  • Loading branch information
lotfio committed Jul 26, 2020
1 parent e30c183 commit 4931e2b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
*
* @copyright 2019 Lotfio Lakehal
*/

$conso->command('command', Conso\Commands\Command::class);
2 changes: 0 additions & 2 deletions conso
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ $conso->setSignature(" ______
$$$$$$/ $$$$$$/ $$/ $$/ $$$$$$$/ $$$$$$/
");

require_once 'commands.php';

$conso->run(0);
6 changes: 4 additions & 2 deletions src/Conso/Conso.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ public function command(string $name, $action): CommandsTable
*/
public function run(int $env = 0)
{
try {
// build in commands
$this->loadBuildInCommands();

try {
// pass table defined commands & match
$this->invokedCommand = $this->linker->link($this->getCommands());

return $this->invoker->invoke($this->invokedCommand);

} catch (\Exception $e) {
if ($this->output->isTestMode()) { // is test mode

Expand Down
11 changes: 11 additions & 0 deletions src/Conso/ConsoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ public function call(string $command): void
passthru($cmd);
}

/**
* load build in commands.
*
* @return void
*/
public function loadBuildInCommands()
{
$conso = $this;
require_once dirname(__DIR__, 2) . '/commands.php';
}

/**
* get available commands method.
*
Expand Down

0 comments on commit 4931e2b

Please sign in to comment.