Main parameter doesn't support Converter
See original GitHub issueThe converter isn’t called and I get an Exception: Exception in thread “main” com.beust.jcommander.ParameterException: Could not invoke null Reason: Can not set java.nio.file.Path field mypackage.MyCommand.file to java.lang.String
@Parameter(description = "File", converter = PathConverter.class)
private Path file;
(The PathConverter is from JCommander)
If I add a name to the Parameter (like -f) then the converter works like a charm.
Whole class: MyCommand.txt
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
HDMI to VGA converter. Input not supported - Super User
If you are using a HDMI to VGA adapter and it is showing "Input not supported" then: First go to your second monitor...
Read more >Xbox to VGA monitor problems - Microsoft Community
I have a HDMI extension cable to a HDMI to VGA converter to my monitor that i use for the 360 all the...
Read more >Solved: P2419HC, VGA to HDMI not working - Dell Community
Solved: I have a pretty basic Lenovo desktop. ... I got a VGA to HDMI cord but the monitor just says "No HDMI...
Read more >jpa inbound-channel-adapter doesn't support parameter source
I am trying to use the parameter-source to provide a parameter to my query in the inbound-channel-adapter but it doesn't seem to work....
Read more >[FEATURE] Support for custom parameter type with ... - GitHub
ParamType, for defining custom parameter types, but it doesn't work ... pragma no cover RuntimeError: Type not yet supported: <__main__.
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 Free
Top 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
1.74 was released about a month ago:
https://bintray.com/cbeust/maven/jcommander/1.74
Thanks for adding converter capability to parse the main param: https://github.com/cbeust/jcommander/blob/05254453c0a824f719bd72dac66fa686525752a5/src/main/java/com/beust/jcommander/JCommander.java#L766-L771
However, the code does not work if we provide
IStringConverterFactory
. A workaround is to specify a dummy converter class for the main parameter that cannot be instantiated.I noticed the solution above
Added a check in JCommander.java testing if Converter is specified and is not a NoConverter.
But the condition https://github.com/cbeust/jcommander/blob/05254453c0a824f719bd72dac66fa686525752a5/src/main/java/com/beust/jcommander/JCommander.java#L769
prevents using the
IStringConverterFactory
. It would be good to callconvertValue
anyway. All in all, if there is no appropriate converter, it would just return the same string https://github.com/cbeust/jcommander/blob/05254453c0a824f719bd72dac66fa686525752a5/src/main/java/com/beust/jcommander/JCommander.java#L1373However, to avoid breaking tests without the condition, should the
if
clause be extended to account forIStringConverterFactory
?