Fixed error when -o is missied
This commit is contained in:
parent
40cc852328
commit
c6094566b4
@ -20,8 +20,13 @@ foreach ($paths as $path) {
|
|||||||
|
|
||||||
is_null($file) && throw new RuntimeException('Unable to locate autoload.php file.');
|
is_null($file) && throw new RuntimeException('Unable to locate autoload.php file.');
|
||||||
|
|
||||||
|
$processor = new Processor($argv);
|
||||||
try {
|
try {
|
||||||
(new Processor($argv))->convert();
|
$processor->convert();
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), PHP_EOL));
|
||||||
|
print(implode(PHP_EOL, $processor->usage()));
|
||||||
|
die(1);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), PHP_EOL));
|
fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), PHP_EOL));
|
||||||
die(1);
|
die(1);
|
||||||
|
@ -22,7 +22,7 @@ class Processor
|
|||||||
/**
|
/**
|
||||||
* Converter version
|
* Converter version
|
||||||
*/
|
*/
|
||||||
public const VERSION = '1.2.0';
|
public const VERSION = '1.2.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[] Paths to collection files
|
* @var string[] Paths to collection files
|
||||||
@ -167,6 +167,9 @@ class Processor
|
|||||||
if (empty($this->collectionPaths)) {
|
if (empty($this->collectionPaths)) {
|
||||||
throw new InvalidArgumentException('there are no collections to convert');
|
throw new InvalidArgumentException('there are no collections to convert');
|
||||||
}
|
}
|
||||||
|
if (empty($this->outputPath)) {
|
||||||
|
throw new InvalidArgumentException('-o is required');
|
||||||
|
}
|
||||||
if (empty($this->formats)) {
|
if (empty($this->formats)) {
|
||||||
$this->formats = [ConvertFormat::Http->name => ConvertFormat::Http];
|
$this->formats = [ConvertFormat::Http->name => ConvertFormat::Http];
|
||||||
}
|
}
|
||||||
@ -285,7 +288,7 @@ class Processor
|
|||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
protected function version(): array
|
public function version(): array
|
||||||
{
|
{
|
||||||
return ["Postman collection converter v" . self::VERSION];
|
return ["Postman collection converter v" . self::VERSION];
|
||||||
}
|
}
|
||||||
@ -293,7 +296,7 @@ class Processor
|
|||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
protected function copyright(): array
|
public function copyright(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Anthony Axenov (c) ' . date('Y') . ", MIT license",
|
'Anthony Axenov (c) ' . date('Y') . ", MIT license",
|
||||||
@ -304,7 +307,7 @@ class Processor
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function usage(): array
|
public function usage(): array
|
||||||
{
|
{
|
||||||
return array_merge($this->version(), [
|
return array_merge($this->version(), [
|
||||||
'Usage:',
|
'Usage:',
|
||||||
|
Loading…
Reference in New Issue
Block a user