Subject: | Optional regex option with required file option results in wrong error message on bad input. |
This is with v0.1.0.
Program has an optional regex option (say "--foo") and a required readable file option. If the
user does not specify the regex option or gives a good value for it, option parsing works.
However, if the user specifies a bad value for the regex option, the resulting error indicates that
the name of the regex option is not a readable file (e.g. "--foo" isn't a valid file), rather than
complaining about the bad regex option value.
Test case in the form used in the distribution attached.
Subject: | fail_optional_regex_with_required_other.t |
use Test::More 'no_plan';
BEGIN {
require 5.006_001 or plan 'skip_all';
close *STDERR;
open *STDERR, '>', \my $stderr;
*CORE::GLOBAL::exit = sub { die $stderr };
}
BEGIN {
$ENUM = 'bad_value';
$FILE = '/dev/null';
@ARGV = (
'--enum', $ENUM,
$FILE,
);
}
if (eval { require Getopt::Euclid and Getopt::Euclid->import(); 1 }) {
ok 0 => 'Unexpectedly succeeded';
}
else {
like $@, qr/$FILE/ => 'Failed as expected';
}
__END__
=head1 NAME
orchestrate - Convert a file to Melkor's .orc format
=head1 VERSION
This documentation refers to orchestrate version 1.9.4
=head1 USAGE
orchestrate --enum [=] {foo|bar} <file>...
=head1 REQUIRED ARGUMENTS
=over
=item <file>...
Specify input files
=for Euclid:
file.type: readable
file.default: '-'
=back
=head1 OPTIONS
=over
=item --enum [=] <value>
=for Euclid:
value.type: /foo|bar/
value.default: 'foo'
=item --version
=item --usage
=item --help
=item --man
Print the usual program information
=back
=begin remainder of documentation here...
=end
=head1 AUTHOR
Damian Conway (damian@conway.org)
=head1 BUGS
There are undoubtedly serious bugs lurking somewhere in this code.
Bug reports and other feedback are most welcome.
=head1 COPYRIGHT
Copyright (c) 2002, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the terms of the Perl Artistic License
(see http://www.perl.com/perl/misc/Artistic.html)