Author: jkeenan
Date: Sat Jan 27 12:16:52 2007
New Revision: 16819
Modified:
branches/buildtools/lib/Parrot/Ops2pm/Auxiliary.pm
branches/buildtools/tools/build/ops2pm.pl
Log:
To improve testability of functionality in ops2pm.pl, refactored options
processing into Parrot::Ops2pm::Auxiliary::getoptions(), then imported that
subroutine into ops2pm.pl.
Modified: branches/buildtools/lib/Parrot/Ops2pm/Auxiliary.pm
==============================================================================
--- branches/buildtools/lib/Parrot/Ops2pm/Auxiliary.pm (original)
+++ branches/buildtools/lib/Parrot/Ops2pm/Auxiliary.pm Sat Jan 27 12:16:52 2007
@@ -5,7 +5,8 @@
use warnings;
use vars qw(@ISA @EXPORT_OK);
@ISA = qw( Exporter );
[EMAIL PROTECTED] = qw( Usage );
[EMAIL PROTECTED] = qw( Usage getoptions );
+use Getopt::Long;
sub Usage {
print STDERR <<_EOF_;
@@ -14,5 +15,15 @@
return 1;
}
+sub getoptions {
+ my %flags;
+ GetOptions(
+ "no-lines" => \$flags{nolines},
+ "help" => \$flags{help},
+ "renum" => \$flags{renum},
+ );
+ return \%flags;
+}
+
1;
Modified: branches/buildtools/tools/build/ops2pm.pl
==============================================================================
--- branches/buildtools/tools/build/ops2pm.pl (original)
+++ branches/buildtools/tools/build/ops2pm.pl Sat Jan 27 12:16:52 2007
@@ -3,29 +3,22 @@
# $Id$
use warnings;
use strict;
-use Data::Dumper;
-$Data::Dumper::Useqq = 1;
use Getopt::Long;
use lib 'lib';
use Parrot::Ops2pm::Utils;
-use Parrot::Ops2pm::Auxiliary qw( Usage );
+use Parrot::Ops2pm::Auxiliary qw( Usage getoptions );
-my ( $nolines_flag, $help_flag, $renum_flag );
-GetOptions(
- "no-lines" => \$nolines_flag,
- "help" => \$help_flag,
- "renum" => \$renum_flag,
-);
+my $flagref = getoptions();
-if ($help_flag or ! @ARGV) {
+if ($flagref->{help} or ! @ARGV) {
Usage();
exit;
}
my $self = Parrot::Ops2pm::Utils->new( {
argv => [ @ARGV ],
- nolines => $nolines_flag,
- renum => $renum_flag,
+ nolines => $flagref->{nolines},
+ renum => $flagref->{renum},
moddir => "lib/Parrot/OpLib",
module => "core.pm",
inc_dir => "include/parrot/oplib",
@@ -35,7 +28,7 @@
$self->prepare_ops();
-if ($renum_flag) {
+if ($flagref->{renum}) {
$self->renum_op_map_file();
exit 0;
}