[Seqan-dev] ArgParseArgument list allowing zero or more items?


Hi SEQAN devs,

I'm writing a program which accepts zero or more FASTA files on the command line, as positional arguments.

If zero files are specified, then it will default to reading from standard input.

I want to write a Seqan argument parser to capture this behaviour. However, I seem stuck with a solution that requires at least one file to be specified.

Here's a sketch of what I have:

   ArgumentParser parser(PROGRAM_NAME);
   addOption(parser, ArgParseOption("f", "foo", "Silly example", ArgParseArgument::INTEGER, "INT"));

   addArgument(parser, ArgParseArgument(ArgParseArgument::STRING, "FASTA_FILE", true));

   ArgumentParser::ParseResult res = parse(parser, argc, argv);

Notice that isListArgument is set to true.

However, when I run my program, and specify zero positional arguments (but some other option arguments), e.g.

    $ myprogram -foo 0

I get the error:

    Not enough arguments were provided.

Is there a way to achieve what I want to do?

I thought I might be able to default the ArgParseArgument to be an empty vector somehow, but couldn't get that to work.

If anyone has used the Python ArgumentParser before, the behaviour I want to emulate is the ability to specify nargs='*'

Cheers,
Bernie