Skip to content

Commit

Permalink
refactor: Making CLI non-breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
byawitz committed Aug 8, 2024
1 parent 7edc16d commit a2271fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"require": {
"php": ">=7.4",
"utopia-php/framework": "1.0.0-RC1",
"utopia-php/framework": "1.0.*",
"utopia-php/di": "0.1.*"
},
"require-dev": {
Expand Down
7 changes: 4 additions & 3 deletions src/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Utopia\CLI;

use Exception;
use Utopia\CLI\Adapters\Generic;
use Utopia\DI\Container;
use Utopia\DI\Dependency;
use Utopia\Http\Hook;
Expand Down Expand Up @@ -81,12 +82,12 @@ class CLI
/**
* CLI constructor.
*
* @param Adapter $adapter
* @param Adapter|null $adapter
* @param array $args
*
* @throws Exception
*/
public function __construct(Adapter $adapter, array $args = [])
public function __construct(Adapter $adapter = null, array $args = [])
{
if (\php_sapi_name() !== 'cli') {
throw new Exception('CLI tasks can only work from the command line');
Expand All @@ -96,7 +97,7 @@ public function __construct(Adapter $adapter, array $args = [])

@\cli_set_process_title($this->command);

$this->adapter = $adapter;
$this->adapter = $adapter ?? new Generic();
$this->container = new Container();
}

Expand Down

0 comments on commit a2271fd

Please sign in to comment.