diff --git a/pm-convert b/pm-convert index 1168f11..6a9ae06 100755 --- a/pm-convert +++ b/pm-convert @@ -1,7 +1,7 @@ #!/usr/bin/env php 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) { fwrite(STDERR, sprintf('ERROR: %s%s', $e->getMessage(), PHP_EOL)); die(1); diff --git a/src/FileSystem.php b/src/FileSystem.php index c137425..1a63685 100644 --- a/src/FileSystem.php +++ b/src/FileSystem.php @@ -1,6 +1,6 @@ collectionPaths)) { throw new InvalidArgumentException('there are no collections to convert'); } + if (empty($this->outputPath)) { + throw new InvalidArgumentException('-o is required'); + } if (empty($this->formats)) { $this->formats = [ConvertFormat::Http->name => ConvertFormat::Http]; } @@ -285,7 +288,7 @@ class Processor /** * @return string[] */ - protected function version(): array + public function version(): array { return ["Postman collection converter v" . self::VERSION]; } @@ -293,7 +296,7 @@ class Processor /** * @return string[] */ - protected function copyright(): array + public function copyright(): array { return [ 'Anthony Axenov (c) ' . date('Y') . ", MIT license", @@ -304,7 +307,7 @@ class Processor /** * @return array */ - protected function usage(): array + public function usage(): array { return array_merge($this->version(), [ 'Usage:',