Revision history for Perl extension MooseX-Getopt
{{$NEXT}}
+ - unbreak Catalyst::Runtime tests (etc) by keeping _getopt_full_usage in the
+ callstack. (RT#82249)
0.49 2012-12-26 10:13:41 PST-0800
- silence a warning in tests if the user does not have YAML::XS installed
die @$warnings, $exception;
}
-#(this is already documented in MooseX::Getopt. But FIXME later, via RT#82195)
-=for Pod::Coverage
- print_usage_text
-=cut
-sub print_usage_text {
+# maintained for backwards compatibility only
+sub _getopt_full_usage
+{
my ($self, $usage) = @_;
print $usage->text;
exit 0;
}
-# maintained for backwards compatibility only
-sub _getopt_full_usage { shift->print_usage_text(@_) }
+#(this is already documented in MooseX::Getopt. But FIXME later, via RT#82195)
+=for Pod::Coverage
+ print_usage_text
+=cut
+sub print_usage_text { shift->_getopt_full_usage(@_) }
sub _usage_format {
return "usage: %c %o";
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More tests => 7;
use Test::Trap;
use Test::NoWarnings 1.04 ':early';
);
}
+{
+ package MyScript2;
+ use Moose;
+
+ with 'MooseX::Getopt';
+ has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
+}
+
+{
+ # some classes (e.g. ether's darkpan and Catalyst::Runtime) overrode
+ # _getopt_full_usage, so we need to keep it in the call stack so we don't
+ # break them.
+ Class::MOP::class_of('MyScript2')->add_before_method_modifier(
+ _getopt_full_usage => sub {
+ print "--- DOCUMENTATION ---\n";
+ },
+ );
+
+ local @ARGV = ('--help');
+ trap { MyScript2->new_with_options };
+ is(
+ $trap->stdout,
+ join("\n", '--- DOCUMENTATION ---', $usage),
+ 'additional text included before normal usage string',
+ );
+}
+