1

How can I get the input order of parameters in JCommander?
I want to know which parameter was input first.
For example

Myapp --cut -- reverse
Myapp --reverse -- cut

Is this possible in Jcommander?
And if so, how?

zx485
  • 28,498
  • 28
  • 50
  • 59
sensn
  • 15
  • 5

1 Answers1

1

One way to achieve your need is instead of define multiple flag.

See Arities (multiple values for parameters)

Then read your command args:

@Parameter(names = "-cmd", variableArity = true)
public List<String> commands= new ArrayList<>();

MyApp -cmd cut reverse -anotherCmd 
Mạnh Quyết Nguyễn
  • 17,677
  • 1
  • 23
  • 51
  • Thanks for your answer. I think I can use it but then I think I can't show the options with usage(). I have to do some further reading on Jcommander. – sensn Mar 07 '20 at 19:37