Comments (11)
@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
, andjablko
.
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.
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.
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.
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.
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.
Thanks for the info, I've been looking for that.
from args4j.
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.
+1 for adding this to the doc. Thanks!
from args4j.
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.
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.
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)
- Parsing with option value delimiter other than "=" does not work HOT 2
- args4j prints actual values as default values (might contain sensitive information) HOT 4
- deprecated CmdLineException ctor says to use another deprecated ctor
- API changes review for args4j HOT 1
- If bean is null, message "X is not a valid option" occurs
- String array parameters with usage cause NPE when not contained in CLI call HOT 2
- Proper Handling of spaces in attributes
- LICENSE file in 2.33 .jar file
- Is this project still maintained? HOT 2
- Infinite loop with one empty argument
- DelimitedOptionHandler.printDefaultValue() throws NPE (when there are no defaults)
- Space in VALUE breaks --foo=VALUE HOT 1
- usage="", handler = StringArrayOptionHandler.class then parser.printUsage() will crash
- Anyone know of a maintained fork of this? HOT 7
- Also parse environment variables
- How to switch off localization?
- option to have both value and boolean HOT 1
- Cannot find tools.jar
- OSS-Fuzz integration
- Java module support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from args4j.