[exim-cvs] exipick: use Pod::Usage

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] exipick: use Pod::Usage
Gitweb: https://git.exim.org/exim.git/commitdiff/cc05007f1dd71890b2b34b7aec5ed12dc5942c73
Commit:     cc05007f1dd71890b2b34b7aec5ed12dc5942c73
Parent:     48ab0b3cd8203744bd9f50765a81473bbbb93de1
Author:     Heiko Schlittermann (HS12-RIPE) <hs@???>
AuthorDate: Thu Oct 17 07:22:54 2019 +0200
Committer:  Heiko Schlittermann (HS12-RIPE) <hs@???>
CommitDate: Thu Oct 17 07:57:15 2019 +0200


    exipick: use Pod::Usage
---
 src/src/exipick.src | 36 ++++++++++--------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)


diff --git a/src/src/exipick.src b/src/src/exipick.src
index a2281f0..da6dbec 100644
--- a/src/src/exipick.src
+++ b/src/src/exipick.src
@@ -18,10 +18,11 @@ use strict;
BEGIN { pop @INC if $INC[-1] eq '.' };
use Getopt::Long;
use File::Basename;
+use Pod::Usage;

-my($p_name)   = $0 =~ m|/?([^/]+)$|;
+my $p_name    = basename $0;
 my $p_version = "20100323.0";
-my $p_usage   = "Usage: $p_name [--help|--version] (see --help for details)";
+my $p_usage   = "Usage: $p_name [--help|--man|--version] (see --help for details)";
 my $p_cp      = <<EOM;
         Copyright (c) 2003-2010 John Jetmore <jj33\@pobox.com>


@@ -39,7 +40,6 @@ my $p_cp      = <<EOM;
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 EOM
-ext_usage(); # before we do anything else, check for --help


$| = 1; # unbuffer STDOUT

@@ -86,13 +86,15 @@ GetOptions(
   'just-vars'   => \$G::just_vars,  # only display vars, no other info
   'show-rules'  => \$G::show_rules, # display compiled match rules
   'show-tests'  => \$G::show_tests, # display tests as applied to each message
+  'man'         => sub { pod2usage(-verbose => 2, -exit => 0, -noperldoc => system('perldoc -V >/dev/null 2>&1')) },
+  'help'        => sub { pod2usage(-verbose => 1, -exit => 0) },
   'version'     => sub {
-        print basename($0) . ": $0\n",
+        print "$p_name: $0\n",
             "build: EXIM_RELEASE_VERSIONEXIM_VARIANT_VERSION\n",
             "perl(runtime): $]\n";
             exit 0;
   },
-) || exit(1);
+) or pod2usage;


 # if both freeze and thaw specified, only thaw as it is less destructive
 $G::freeze = undef               if ($G::freeze && $G::thaw);
@@ -1266,34 +1268,16 @@ sub dump {


} # BEGIN

-sub ext_usage {
-  if ($ARGV[0] =~ /^--help$/i) {
-    require Config;
-    $ENV{PATH} .= ":" unless $ENV{PATH} eq "";
-    $ENV{PATH} = "$ENV{PATH}$Config::Config{'installscript'}";
-    #exec("perldoc", "-F", "-U", $0) || exit 1;
-    $< = $> = 1 if ($> == 0 || $< == 0);
-    exec("perldoc", $0) || exit 1;
-    # make parser happy
-    %Config::Config = ();
-  } elsif ($ARGV[0] =~ /^--version$/i) {
-    print "$p_name version $p_version\n\n$p_cp\n";
-  } else {
-    return;
-  }
-
-  exit(0);
-}
-
 __END__


=head1 NAME

-exipick - selectively display messages from an Exim queue
+ exipick - selectively display messages from an Exim queue

=head1 SYNOPSIS

-exipick [<options>] [<criterion> [<criterion> ...]]
+ exipick [<options>] [<criterion> [<criterion> ...]]
+ exipick --help|--man

=head1 DESCRIPTION