Skip Menu |

This queue is for tickets about the Getopt-Euclid CPAN distribution.

Report information
The Basics
Id: 61310
Status: resolved
Priority: 0/
Queue: Getopt-Euclid

People
Owner: Nobody in particular
Requestors: SILASMONK [...] cpan.org
Cc: daniel.dehennin [...] baby-gnu.org
AdminCc:

Bug Information
Severity: Normal
Broken in: v0.2.2
Fixed in: (no value)



CC: daniel.dehennin [...] baby-gnu.org
Subject: Documentation unclear: Must there be at most one repeatable argument which must be final?
Using the attached sample file try running ./test.pl --groups=hhh -h=blah and other variations. (Also try commenting out --hosts as an argument.) This all seems to indicate that if you have a repeatable argument then anything that follows will be interpreted as part of that argument. This might be a bug or could possibly be clarified in the documentation.
Subject: test.pl
#!/usr/bin/perl -w use strict; use warnings; use Getopt::Euclid; use Data::Dumper; print Dumper(%ARGV); exit 1; __END__ =head1 NAME test.pl - sample Getopt::Euclid test program =head1 REQUIRED ARGUMENTS =over =item --groups [=] <group>... | -g [=] <group>... List of groups =for Euclid: group.type: string =item --hosts [=] <hostname>... | -h <hostname>... List of hostnames. =back =cut
Subject: [rt.cpan.org #61310] Documentation unclear: Must there be at most one repeatable argument which must be final?
Date: Thu, 16 Jun 2011 15:26:40 +0200
To: bug-Getopt-Euclid [...] rt.cpan.org
From: Daniel Dehennin <daniel.dehennin [...] baby-gnu.org>
Hello, The same apply with optional placeholders. I wanted to have an option with an optional argument: - if the option is not specified, do not use it, - if the option is specified without the optional argument, then use a default value define somewhere[1], - if the option is specified with the optional argument, use that optional argument. I think it should looks like this: #v+ imaginary exemples ./test-optional-placeholders.pl option2 is 'value2' ./test-optional-placeholders.pl --enable-opt2 option2 is 'value2' ./test-optional-placeholders.pl --enable-opt2 'different value 2' option2 is 'different value 2' ./test-optional-placeholders.pl --enable-opt1 option1 is 'default value 1' option2 is 'value2' ./test-optional-placeholders.pl --enable-opt1 'different value 1' option1 is 'different value 1' option2 is 'value2' ./test-optional-placeholders.pl --enable-opt1 'different value 1' --enable-opt2 option1 is 'different value 1' option2 is 'value2' ./test-optional-placeholders.pl --enable-opt1 'different value 1' --enable-opt2 'different value 2' option1 is 'different value 1' option2 is 'different value 2' ./test-optional-placeholders.pl --enable-opt1 --enable-opt2 option1 is 'default value 1' option2 is 'value2' ./test-optional-placeholders.pl --enable-opt1 --enable-opt2 'different value 2' option1 is 'default value 1' option2 is 'different value 2' #v- In practice, a problem arise when the optional argument to --enable-opt1 is omitted: #v+ ./test-optional-placeholders.pl --enable-opt1 --enable-opt2 option1 is '--enable-opt2' option2 is 'value2' ./test-optional-placeholders.pl --enable-opt1 --enable-opt2 'different value 2' option1 is '--enable-opt2'' option2 is 'different value 2' #v- The optional placeholder eat the next option, like with multiple placeholders, options should be excluded. 1. An optional placeholder should not be fed by an option. 2. A multiple placeholder should stopped to be fed when an option is encountered. With those points, a policy on what to do with non-option single/double-dash starting strings are encounter in that case: #v+ ./test-optional-placeholders.pl --enable-opt1 --not-an-option-defined-in-getopt-euclid --enable-opt2 #v- - An unknown option error? I think it's the saner one, it permit to detect typos on command lines - option1 is '--not-an-option-defined-in-getopt-euclid' ? Regards. Footnotes: [1] like at the top of the script -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
Download (untitled)
application/pgp-signature 197b

Message body not shown because it is not plain text.

Silasmonk > I cannot seem to reproduce your issue. Multiple arguments that have multiple placeholders are handled fine. Have you tried the latest version of Getopt::Euclid, 0.2.8? Daniel > As of version 0.2.8, optional placeholders can have a default using the opt_default directive.