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.

Need way to automatically show usage if required params are missing

See original GitHub issue

Currently if you specify help = true in a parameter, exceptions are suppressed. However, you then have to manually check for required parameters not being set.

It would be great if there were a way to prevent exceptions from being thrown on missing required parameters, but print the usage text instead. Maybe in addition to adding help = true to a help parameter, you could also specify usage = true, and if a parameter is missing, even if the help option was not given on the commandline, JCommander could set the help parameter value to true, so that the usage text is displayed?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cbeustcommented, Mar 18, 2017

How about adding the JCommander instance to the ParameterException?

– Cédric

On Fri, Mar 17, 2017 at 10:35 PM, Luke Hutchison notifications@github.com wrote:

The reason the current pattern is problematic is that you don’t have a JCommander reference if the constructor throws an exception, so you can’t call the usage() method if there is a missing parameter, unless there is a help = true parameter. But if there is a help = true parameter, you don’t get built-in required parameter checking. It’s not possible currently to get both built-in required parameter checking and be able to display usage info if there is a missing required parameter.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cbeust/jcommander/issues/337#issuecomment-287518329, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFoogF0XAyCt8LPTKvLv4q20wob6W_Wks5rm20rgaJpZM4MhTPZ .

0reactions
cbeustcommented, Apr 8, 2017

Oops, my mistake. Fixed and deployed in 1.68.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing required parameters in Route - laravel - Stack Overflow
Hi, I have problem with routes, it's always return "Missing Required Parameters".Please see my code below. Thank you! I think my route is...
Read more >
Integromat - Error "Missing value of required parameter 'URL'."
I am trying to configure an Integromat scenario that takes the photos of each S123 and stores them on a Google Drive File...
Read more >
Parameter Actions - Tableau Help
You can use parameter actions with reference lines, calculations, filters, and SQL queries, and to customize how you display data in your visualizations....
Read more >
Check if Google Ads auto-tagging works - Analytics Help
If you don't see the gclid parameter appended to your URLs after the page is fully loaded, then it's likely that your website...
Read more >
Fail-fast on missing required arguments in JavaScript using ...
JavaScript doesn't automatically throw an error if the argument for a required parameter is missing. Which means that it is possible for ...
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