Compare commits

..

No commits in common. "c790adf611c743545b427f62ffda61ca32166ab3" and "0ac5e64c17514bb3b020efef7a11d76d093a8400" have entirely different histories.

3 changed files with 7 additions and 15 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
declare(strict_types=1); declare(strict_types = 1);
use PmConverter\Processor; use PmConverter\Processor;
@ -20,13 +20,8 @@ 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 {
$processor->convert(); (new Processor($argv))->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);

View File

@ -1,6 +1,6 @@
<?php <?php
declare(strict_types=1); declare(strict_types = 1);
namespace PmConverter; namespace PmConverter;

View File

@ -22,7 +22,7 @@ class Processor
/** /**
* Converter version * Converter version
*/ */
public const VERSION = '1.2.1'; public const VERSION = '1.2.0';
/** /**
* @var string[] Paths to collection files * @var string[] Paths to collection files
@ -167,9 +167,6 @@ 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];
} }
@ -288,7 +285,7 @@ class Processor
/** /**
* @return string[] * @return string[]
*/ */
public function version(): array protected function version(): array
{ {
return ["Postman collection converter v" . self::VERSION]; return ["Postman collection converter v" . self::VERSION];
} }
@ -296,7 +293,7 @@ class Processor
/** /**
* @return string[] * @return string[]
*/ */
public function copyright(): array protected function copyright(): array
{ {
return [ return [
'Anthony Axenov (c) ' . date('Y') . ", MIT license", 'Anthony Axenov (c) ' . date('Y') . ", MIT license",
@ -307,7 +304,7 @@ class Processor
/** /**
* @return array * @return array
*/ */
public function usage(): array protected function usage(): array
{ {
return array_merge($this->version(), [ return array_merge($this->version(), [
'Usage:', 'Usage:',