Re: [Seqan-dev] ArgParseArgument list allowing zero or more items?
- From: Bernard James Pope <bjpope@unimelb.edu.au>
- To: SeqAn Development <seqan-dev@lists.fu-berlin.de>
- Date: Fri, 29 Jul 2016 06:48:38 +0000
- Authentication-results: spf=pass (sender IP is 128.250.6.44) smtp.mailfrom=unimelb.edu.au; lists.fu-berlin.de; dkim=none (message not signed) header.d=none;lists.fu-berlin.de; dmarc=pass action=none header.from=unimelb.edu.au;
- Reply-to: SeqAn Development <seqan-dev@lists.fu-berlin.de>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
- Subject: Re: [Seqan-dev] ArgParseArgument list allowing zero or more items?
Thanks René,
I have posted my question there.
Cheers,
Bernie
> On 28 Jul 2016, at 8:00 pm, Rahn, René <rene.maerker@fu-berlin.de> wrote:
>
> Hi Bernie,
>
> thank you very much for writing us.
> I'd like you to raise such questions on the issue site on our github page: https://github.com/seqan/seqan/issues.
> The mailing list is not-so-up-to-date anymore, and we will probably use this mailing list merely as a news feeder in the future to inform you about new releases or training courses.
>
> Thank you very much for you understanding.
>
> Kind regards,
>
> René
>
>> On 10 Jul 2016, at 08:35, 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
>
> ---
>
> René Rahn
> Ph.D. Student (de.NBI - CIBI)
> --------------------------------
> Tel: (+49) 30 838 75137
> Mail: rene.rahn@fu-berlin.de
> --------------------------------
> Institute of Computer Science
> Algorithmic Bioinformatics (ABI)
> --------------------------------
> Freie Universität Berlin
> Takustraße 9
> 14195 Berlin
> --------------------------------
>
> _______________________________________________
> seqan-dev mailing list
> seqan-dev@lists.fu-berlin.de
> https://lists.fu-berlin.de/listinfo/seqan-dev