question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exit on help, version or invalid arguments

See original GitHub issue

Typically, when you run a command line application using the help or version flag (--help, --version) you expect that the program exits itself after printing usage information.

Picocli has a built-in feature to alleviate the programmer of writing the help and version logic, but in this case Picocli doesn’t exit application —invoking for example system exit with a status code of success— but let the application to continue running.

When using the convenience CommandLine.run(), CommandLine.call() I would expect the described behavior to happen. Currently, usage information is printed but application doesn’t exit and continues running with no simple way to configure it to work as described (related discussion: #397 ).

I propose to print usage and exit to be the default behavior. I don’t know if any other use case could need the application to continue but in that case I would propose an annotation based configuration to override the defaults like the one proposed in ticket #397 .

Kind regards!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
remkopcommented, Aug 1, 2018

Glad to hear that. Sounds like you would like to see documentation on using picocli with Spring Boot. I don’t have any experience with Spring, so contributions / pull requests welcome!

About the original request: I like the idea of having annotations to control the exit code on usage help and version info, and I will probably add this in a future release.

0reactions
gerardboschcommented, May 14, 2019

Thanks @remkop , I cannot check it out at this moment, but I keep it present 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exit Code when called with No Arguments - Stack Overflow
I have a script that requires at least one argument. If the arguments are incorrect I will obviously return a non ...
Read more >
SQLite3.exe - How to use arguments AND ... - SQLite Forum
Enter ".help" for help D:\Debug>sqlite3.exe .help SQLite version 3.36.0 ... OPTIONS include: -A ARGS... run ".archive ARGS" and exit -append ...
Read more >
How to handle invalid arguments with argparse in Python?
First run: the arguments are geek 12345678. The username should have at least 5 characters. · Second run: the arguments are geeks 12345678....
Read more >
Command Line Arguments
In addition to this exit code, the ID of the built product is output to STDOUT. 1: Invalid arguments, either an invalid combination...
Read more >
Troubleshooting AWS CLI errors - AWS Command Line Interface
Confirm that you're running a recent version of the AWS CLI ... aws <command> help aws <command> <subcommand> help aws: error: argument subcommand:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found