]> git.donarmstrong.com Git - debbugs.git/commitdiff
The wheezy getopt::long basically doesn't support any of the OO stuff. Switch back...
authorDon Armstrong <don@donarmstrong.com>
Wed, 6 Aug 2014 23:03:03 +0000 (16:03 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 6 Aug 2014 23:03:03 +0000 (16:03 -0700)
bin/debbugs-loadsql

index d6096ba461ad0f38b60159fe5f7ad934aa9ae261..8335c7d2f5e243a28aeb2cc01336b8c7a5434f72 100755 (executable)
@@ -119,18 +119,17 @@ my %options =
      progress        => 0,
     );
 
-my $gop = Getopt::Long::Parser->new();
-$gop->configure('pass_through');
-$gop->getoptions(\%options,
-                 'quick|q',
-                 'service|s',
-                 'sysconfdir|c',
-                 'progress!',
-                 'spool_dir|spool-dir=s',
-                 'verbose|v+',
-                 'quiet+',
-                 'debug|d+','help|h|?','man|m');
-$gop->getoptions('default');
+Getopt::Long::Configure('pass_through');
+GetOptions(\%options,
+           'quick|q',
+           'service|s',
+           'sysconfdir|c',
+           'progress!',
+           'spool_dir|spool-dir=s',
+           'verbose|v+',
+           'quiet+',
+           'debug|d+','help|h|?','man|m');
+Getopt::Long::Configure('default');
 
 pod2usage() if $options{help};
 pod2usage({verbose=>2}) if $options{man};
@@ -186,11 +185,15 @@ if ($options{progress}) {
 my ($subcommand) = shift @ARGV;
 if (not defined $subcommand) {
     $subcommand = 'help';
-    print STDERR "You must provide a subcommand; displaying help";
+    print STDERR "You must provide a subcommand; displaying usage.\n";
+    pod2usage();
+} elsif (not exists $subcommands{$subcommand}) {
+    print STDERR "$subcommand is not a valid subcommand; displaying usage.\n";
+    pod2uage();
 }
 
 my $opts =
-    handle_subcommand_arguments(\@ARGV,$subcommands{$subcommand}{arguments},$gop);
+    handle_subcommand_arguments(\@ARGV,$subcommands{$subcommand}{arguments});
 $subcommands{$subcommand}{function}->(\%options,$opts,$prog_bar,\%config,\@ARGV);
 
 sub add_bugs {
@@ -415,7 +418,7 @@ sub add_logs {
 }
 
 sub handle_subcommand_arguments {
-    my ($argv,$args,$gop) = @_;
+    my ($argv,$args) = @_;
     my $subopt = {};
     Getopt::Long::GetOptionsFromArray($argv,
                               $subopt,