java - command line parsing using apache commons cli -


Tryng to use m apache commons cli, my use case is the variable number of arguments with some options.

Say

  -p str1 str2;   

this could be

  -p str1 str2 str3. Strn   

another

  -m str1 -h   

with

  cmdline.getOptionValues ​​("p");   

This only brings the final string. How can I get all the values ​​of a particular option?

Edit:

  if (Cmdline.hasOption ("p")) {string [] argsList = cmdline.getOptionValues ​​(p); String string = arrays.toString (argsList); ArgsList = strLine.split (","); }   

Am I doing this right? Should I get accurate data in the string that I want or unknowingly add white spaces to someone else?

Use isres () with a value separator set to a comma , Then the option becomes

  -p str1, str2, str3, ..., strn   

CLI < How to manage multi-valuable options in / html>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -