Parameters must be prefixed with - or --
See original GitHub issueThis is not mentioned in the documentation and the error message isn’t obvious.
Demonstration code:
class P1 {
@Parameter(names = "hello")
private int test;
}
P1 p1 = new P1();
JCommander j = new JCommander(p1);
j.parse(new String[]{"hello", "47"});
System.out.printf("command %s, test %d\n", j.getParsedCommand(), p1.test);
Raises:
Exception in thread "main" com.beust.jcommander.ParameterException: Was passed main parameter 'hello' but no main parameter was defined
at com.beust.jcommander.JCommander.getMainParameter(JCommander.java:914)
at com.beust.jcommander.JCommander.parseValues(JCommander.java:759)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at test.main.main(main.java:18)
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Function parameter name with "In" prefix?
I understand the “Out” prefix for parameter name, but what does “In” prefix mean? There is no info about it in Coding Standards...
Read more >Why am I getting an error when querying SSM parameters via ...
The parameter name must begin with a forward slash "/". It can't be prefixed with "aws" or "ssm" (case-insensitive). It must use only...
Read more >What are the benefits of prefixing function parameter names ...
Even if you needed such number of variables - they should use meaningful names and the prefix is standing between you and the...
Read more >CA1715: Identifiers should have correct prefix (code analysis)
Learn about code analysis rule CA1715: Identifiers should have correct prefix.
Read more >clish / Discussion / Help: Problem with "Prefix" - SourceForge
So rather then just loop from 0 - paramc it should look for all the prefix parameters and do completion on those first....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Indeed, feel free to send a PR for the documentation.
Speaking of documentation, I’d also like to update the CSS so we can have the table of contents on the side and in a fixed position instead of at the top where it takes up most of the first screen before your scroll.
Fixed in 1.61. Here is a version of your code above that works: