GithubHelp home page GithubHelp logo

Comments (11)

dimo414 avatar dimo414 commented on June 18, 2024 2

@thammegowda note that the Javadoc for StringArrayOptionHandler indicates this is expected behavior:

All of [these examples] result in a single string array that contains three tokens: banan, hruska, and jablko.

If you need proper quoting support it might be better to use the default behavior and use the flag repeatedly, i.e.:

-in "United States" -in "United Kingdom"

from args4j.

micheljung avatar micheljung commented on June 18, 2024

We're also using multiValued. If the option doesn't hurt, i think you should left it to the user whether it makes sense or not.

from args4j.

devent avatar devent commented on June 18, 2024

Hello, I was using the multiValues attribute, too.

I guess I could use just a single value argument and pass multiple values separated by a comma. In example, instead:
-in fileA -in fileB -in fileC
You could use:
-in fileA,fileB,fileC

Of course you need to take into account if the file have a comma in the name but you can just force your users to escape the comma:
-in file,A,fileB,fileC

from args4j.

arahuja avatar arahuja commented on June 18, 2024

Is there an alternative to using multiValued in there, or a reason it was taken out? Is there interest a contribution to add it back in?

from args4j.

jaredpetker avatar jaredpetker commented on June 18, 2024

Who knows if anyone here cares or not still, but seems like multivalue just works if you use a list... see here -> multivalued test for more info.

from args4j.

abreksa4 avatar abreksa4 commented on June 18, 2024

@jaredpetker

Thanks for the info, I've been looking for that.

from args4j.

dessalines avatar dessalines commented on June 18, 2024

Finally figured out how to do this. It should really be added to the main example, considering how useful it is, (and considering I had to do work to figure out how to do it)
but here's the solution:

@Option(name = "-in", handler=StringArrayOptionHandler.class")
private List<String> inFiles;

Then you can use, -in <item1> <item2>

from args4j.

AshwinJay avatar AshwinJay commented on June 18, 2024

+1 for adding this to the doc. Thanks!

from args4j.

thammegowda avatar thammegowda commented on June 18, 2024

I had to pass

-in "United States" "United Kingdom"

Found that the handler is breaking it into four words : [United, States, United, Kingdom]
but I expected two words : [United States, United Kingdom]

Warning:Stay away from this if your argument values consists of multiwords with spaces.

from args4j.

70m4 avatar 70m4 commented on June 18, 2024

Hi all,

I found maybe a bug when I configure an option like that:

@Option(name = "-in", handler=StringArrayOptionHandler.class")
private List<String> inFiles;

When I do this call (no operands):
myApp -in

There are no exceptions thrown to tell that there are no operands.

StringArrayOptionHandler.parseArguments will return 0
and the test in CmdLineParser.getParameter(int ) does not fail like it does with a simple string option

from args4j.

ooxi avatar ooxi commented on June 18, 2024

There are no exceptions thrown to tell that there are no operands. StringArrayOptionHandler.parseArguments will return 0

I would consider this the correct behaviour, since an empty list looks totally fine to me

from args4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.