Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Exit status should be 1 when no/wrong arguments are passed #132

Closed
jmini opened this issue May 22, 2018 · 4 comments
Closed

CLI: Exit status should be 1 when no/wrong arguments are passed #132

jmini opened this issue May 22, 2018 · 4 comments

Comments

@jmini
Copy link
Member

jmini commented May 22, 2018

Inspired by #124

When the cli is run with wrong or no arguments, it returns the text:

Available languages (generators): [ada, ada-server, android, apache2, apex, aspnetcore, bash, clojure, cwiki, cpp-qt5, cpp-pistache-server, cpp-restbed-server, cpp-restsdk, cpp-tizen, csharp, csharp-dotnet2, csharp-nancyfx, dart, eiffel, elixir, elm, erlang-client, erlang-server, flash, scala-finch, go, go-server, groovy, kotlin, kotlin-server, haskell-http-client, haskell, java, jaxrs-cxf-client, java-inflector, java-msf4j, java-pkmst, java-play-framework, java-undertow-server, java-vertx, jaxrs-cxf, jaxrs-cxf-cdi, jaxrs-jersey, jaxrs-resteasy, jaxrs-resteasy-eap, jaxrs-spec, javascript, javascript-closure-angular, jmeter, lua, nodejs-server, objc, openapi, openapi-yaml, perl, php, php-lumen, php-slim, php-silex, php-symfony, php-ze-ph, powershell, python, python-flask, r, ruby, ruby-on-rails, ruby-sinatra, rust, rust-server, scalatra, scala-akka, scala-httpclient, scala-gatling, scala-lagom-server, scalaz, spring, dynamic-html, html, html2, swift2-deprecated, swift3, swift4, typescript-angular, typescript-angularjs, typescript-aurelia, typescript-fetch, typescript-inversify, typescript-jquery, typescript-node]

Take this bash script:

#!/bin/sh

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar
STATUS="${?}"
echo "Status: ${STATUS}"

The error status should be 1 and not 0

@jmini
Copy link
Member Author

jmini commented May 22, 2018

When this is implemented, the bin/run-all-petstore should use set -e (see https://stackoverflow.com/a/1379904) in order to propagate the error code back.

@jimschubert
Copy link
Member

@jmini set -e will cause bin/run-all-petstore.sh to fail in first error. This usually isn't desirable behavior on CI.

We probably want to echo to stdout if a generator has errored, by inspection $?.

@jimschubert
Copy link
Member

Also, looking at this a little more closely, exiting with status 1 will prevent scripts from piping Langs output to another command and parsing it. I'll look into whether the framework can define an exit code of 1 only when the commands is defaulted.

@jmini
Copy link
Member Author

jmini commented May 23, 2018

PRs:

@jmini jmini closed this as completed May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants