Reputation: 4700
I'm trying to use Argparse4j to build a command line utility. I need to create an option that accepts multiple input files, but also accepts stdin:
subparser.addArgument("input")
.nargs("*")
.setDefault(Arrays.asList("-"))
.type(Arguments.fileType().acceptSystemIn().verifyCanRead());
If I don't use Arrays.asList
, then sometimes I get just a File
object, instead of a List<File>
.
However, using nargs("*")
also makes it so that I get "-" (as a String) in the list, instead of an actual File
object.
Has anyone had any success with something similar?
Upvotes: 1
Views: 275
Reputation: 404
argparse4j does not do any conversion against the value passed by setDefault()
. So you need to pass Arrays.asList(new File("-"))
to setDefault()
to get desired effect.
Upvotes: 1