Re: [Seqan-dev] ArgParseArgument list allowing zero or more items?
I think I’m confused the present way you have it would have the an option and an argument.
my program -foo 0 somefasta.fasta
In this case, what is the point of foo?
Since you put the fasta file as an argument and not an option, it must be specified. I think what you want is to add the fasta file as an option then use the getOptionValue method to see if it has been used.
Jordan
> On Jul 9, 2016, at 11:35 PM, Bernard James Pope <bjpope@unimelb.edu.au> wrote:
>
> 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
> _______________________________________________
> seqan-dev mailing list
> seqan-dev@lists.fu-berlin.de
> https://lists.fu-berlin.de/listinfo/seqan-dev