tag:blogger.com,1999:blog-32637828.post396805847552688927..comments2023-10-31T16:37:25.528+00:00Comments on fahd.blog: Args4j vs JCommander for Parsing Command Line ParametersFahd Shariffhttp://www.blogger.com/profile/00919911016127601294noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-32637828.post-57339875652803732492014-01-29T05:46:10.164+00:002014-01-29T05:46:10.164+00:00I want to know about jcommander.. so any one can h...I want to know about jcommander.. so any one can help me in writing a simple program on jcommander that how to parse argument from command line.i want to use two commands like 1-Run & 2- List command. Anonymoushttps://www.blogger.com/profile/10319133722582894862noreply@blogger.comtag:blogger.com,1999:blog-32637828.post-500163371128037272012-11-26T07:48:57.099+00:002012-11-26T07:48:57.099+00:00Correction, Args4j can have boolean options with p...Correction, Args4j can have boolean options with params, but you have to use a different OptionHandler:<br /><br />http://java.net/jira/browse/ARGS4J-12?focusedCommentId=350653&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_350653Sean Flaniganhttps://www.blogger.com/profile/13615385115176751260noreply@blogger.comtag:blogger.com,1999:blog-32637828.post-58744942392838864162012-11-26T05:30:55.705+00:002012-11-26T05:30:55.705+00:00Thanks for the handy comparison!
I think #2 (@Par...Thanks for the handy comparison!<br /><br />I think #2 (@Parameter on a setter method) has been implemented in JCommander recently: https://groups.google.com/d/topic/jcommander/EchNx4rJFGE/discussion<br /><br />I've been using args4j for a while, but it's got one shortcoming that annoys me: boolean options are always flags; they can't take a parameter. So you can't have a boolean option which defaults to true, where the user says: 'mycommand --flag=false' to turn the flag off. (You can work around it by using String instead of boolean, but then you have to convert String->boolean in the setter method.)Sean Flaniganhttps://www.blogger.com/profile/13615385115176751260noreply@blogger.comtag:blogger.com,1999:blog-32637828.post-43409846077060538472012-01-26T08:46:04.453+00:002012-01-26T08:46:04.453+00:00I don't think that `@DynamicParameter` has bee...I don't think that `@DynamicParameter` has been released yet because it is not in the latest version (1.20). Good to know that it is coming up though!Fahd Shariffhttps://www.blogger.com/profile/00919911016127601294noreply@blogger.comtag:blogger.com,1999:blog-32637828.post-62091160278534806122012-01-26T05:28:17.661+00:002012-01-26T05:28:17.661+00:00JCommander has a built-in way to do the -Dkey=valu...JCommander has a built-in way to do the -Dkey=value pattern: @DynamicParameter. It must be on a field of type Map. You can customize the assignment character (defaults to "=").<br /><br />Agree on the lack of metaVar though, that's killing me.reganhttps://www.blogger.com/profile/04290248770162065260noreply@blogger.com