Fixed execution without params
This commit is contained in:
parent
47930b010f
commit
e5dad3f2d6
@ -44,6 +44,9 @@ class Environment implements ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function readFromFile(string $filepath): static
|
public function readFromFile(string $filepath): static
|
||||||
{
|
{
|
||||||
|
if (empty($filepath)) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
$content = file_get_contents(static::$filepath = $filepath);
|
$content = file_get_contents(static::$filepath = $filepath);
|
||||||
$content = json_decode($content, flags: JSON_THROW_ON_ERROR); //TODO try-catch
|
$content = json_decode($content, flags: JSON_THROW_ON_ERROR); //TODO try-catch
|
||||||
$content || throw new JsonException("not a valid environment: $filepath");
|
$content || throw new JsonException("not a valid environment: $filepath");
|
||||||
|
@ -26,7 +26,7 @@ class Processor
|
|||||||
/**
|
/**
|
||||||
* Converter version
|
* Converter version
|
||||||
*/
|
*/
|
||||||
public const VERSION = '1.6.0';
|
public const VERSION = '1.6.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Initial timestamp
|
* @var int Initial timestamp
|
||||||
@ -62,6 +62,8 @@ class Processor
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param array $argv Arguments came from cli
|
* @param array $argv Arguments came from cli
|
||||||
|
* @throws IncorrectSettingsFileException
|
||||||
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function __construct(protected readonly array $argv)
|
public function __construct(protected readonly array $argv)
|
||||||
{
|
{
|
||||||
@ -83,7 +85,9 @@ class Processor
|
|||||||
*/
|
*/
|
||||||
protected function parseArgs(): void
|
protected function parseArgs(): void
|
||||||
{
|
{
|
||||||
foreach ($this->argv as $idx => $arg) {
|
$arguments = array_slice($this->argv, 1);
|
||||||
|
$needHelp = count($arguments) === 0 && !$this->settings::fileExists();
|
||||||
|
foreach ($arguments as $idx => $arg) {
|
||||||
switch ($arg) {
|
switch ($arg) {
|
||||||
case '-f':
|
case '-f':
|
||||||
case '--file':
|
case '--file':
|
||||||
@ -162,9 +166,13 @@ class Processor
|
|||||||
|
|
||||||
case '-h':
|
case '-h':
|
||||||
case '--help':
|
case '--help':
|
||||||
die(implode(EOL, $this->usage()) . EOL);
|
$needHelp = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($needHelp) {
|
||||||
|
die(implode(EOL, $this->usage()) . EOL);
|
||||||
|
}
|
||||||
if (empty($this->settings->collectionPaths())) {
|
if (empty($this->settings->collectionPaths())) {
|
||||||
throw new InvalidArgumentException('there are no collections to convert');
|
throw new InvalidArgumentException('there are no collections to convert');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user