USAGE method not displaying possible Object values for List of Objects

19 views
Skip to first unread message

mjandersonjr

unread,
Apr 1, 2019, 4:27:58 PM4/1/19
to jcommander
I'm using JCommander 1.72. 
--------------------

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;

import java.util.ArrayList;
import java.util.List;

public class Main2 {

public enum ChoiceType { ONE, TWO, THREE };
@Parameter(names = "-choice")
public ChoiceType choice = ChoiceType.ONE;

@Parameter(names = "-choices", variableArity = true)
public List<ChoiceType> choices = new ArrayList<ChoiceType>();

public static void main(String[] args1) {
Main2 args = new Main2();
String[] argv = { "-choice", "ONE"};
JCommander jc = new JCommander(args, argv);
jc.usage();
}
}

-------------
output:
-------------

Usage: <main class> [options]
  Options:
    -choice
      Options: [ONE, Two, THREE]
      Default: ONE
      Possible Values: [ONE, Two, THREE]
    -choices

      Default: []

------------------------
Is there an option I can set to make the possible values display for the "choices" variable, like it does for the "choice" variable?

Cédric Beust ♔

unread,
Apr 1, 2019, 4:30:43 PM4/1/19
to jcommander
No. It would have to be very specific code too (i.e. "container of an enum type"), so I'm not sure it's worth the trouble...

-- 
Cédric



--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages