PATCH: perldoc in MAINT branch (probably unstable too)
[p5sagit/p5-mst-13.2.git] / lib / Pod / Usage.pm
index aa3a009..771cff4 100644 (file)
@@ -1,7 +1,7 @@
 #############################################################################
 # Pod/Usage.pm -- print usage messages for the running script.
 #
-# Copyright (C) 1996-1999 by Bradford Appleton. All rights reserved.
+# Copyright (C) 1996-2000 by Bradford Appleton. All rights reserved.
 # This file is part of "PodParser". PodParser is free software;
 # you can redistribute it and/or modify it under the same terms
 # as Perl itself.
@@ -10,8 +10,8 @@
 package Pod::Usage;
 
 use vars qw($VERSION);
-$VERSION = 1.090;  ## Current version of this package
-require  5.004;    ## requires this Perl version or later
+$VERSION = 1.14;  ## Current version of this package
+require  5.005;    ## requires this Perl version or later
 
 =head1 NAME
 
@@ -46,7 +46,7 @@ B<pod2usage> should be given either a single argument, or a list of
 arguments corresponding to an associative array (a "hash"). When a single
 argument is given, it should correspond to exactly one of the following:
 
-=over
+=over 4
 
 =item *
 
@@ -68,7 +68,7 @@ assumed to be a hash.  If a hash is supplied (either as a reference or
 as a list) it should contain one or more elements with the following
 keys:
 
-=over
+=over 4
 
 =item C<-message>
 
@@ -80,6 +80,9 @@ program's usage message.
 =item C<-exitval>
 
 The desired exit status to pass to the B<exit()> function.
+This should be an integer, or else the string "NOEXIT" to
+indicate that control should simply be returned without
+terminating the invoking process.
 
 =item C<-verbose>
 
@@ -129,7 +132,7 @@ Unless they are explicitly specified, the default values for the exit
 status, verbose level, and output stream to use are determined as
 follows:
 
-=over
+=over 4
 
 =item *
 
@@ -159,7 +162,7 @@ Although the above may seem a bit confusing at first, it generally does
 "the right thing" in most situations.  This determination of the default
 values to use is based upon the following typical Unix conventions:
 
-=over
+=over 4
 
 =item *
 
@@ -395,6 +398,7 @@ with re-writing this manpage.
 use strict;
 #use diagnostics;
 use Carp;
+use Config;
 use Exporter;
 use File::Spec;
 
@@ -474,7 +478,7 @@ sub pod2usage {
     unless ((ref $opts{"-input"}) || (-e $opts{"-input"})) {
         my ($dirname, $basename) = ('', $opts{"-input"});
         my $pathsep = ($^O =~ /^(?:dos|os2|MSWin32)$/) ? ";"
-                            : (($^O eq 'MacOS') ? ',' :  ":");
+                            : (($^O eq 'MacOS' || $^O eq 'VMS') ? ',' :  ":");
         my $pathspec = $opts{"-pathlist"} || $ENV{PATH} || $ENV{PERL5LIB};
 
         my @paths = (ref $pathspec) ? @$pathspec : split($pathsep, $pathspec);
@@ -497,8 +501,19 @@ sub pod2usage {
     }
 
     ## Now translate the pod document and then exit with the desired status
-    $parser->parse_from_file($opts{"-input"}, $opts{"-output"});
-    exit($opts{"-exitval"});
+    if ( $opts{"-verbose"} >= 2 
+             and  !ref($opts{"-input"})
+             and  $opts{"-output"} == \*STDOUT )
+    {
+       ## spit out the entire PODs. Might as well invoke perldoc
+       my $progpath = File::Spec->catfile($Config{bin}, "perldoc");
+       system($progpath, $opts{"-input"});
+    }
+    else {
+       $parser->parse_from_file($opts{"-input"}, $opts{"-output"});
+    }
+
+    exit($opts{"-exitval"})  unless (lc($opts{"-exitval"}) eq 'noexit');
 }
 
 ##---------------------------------------------------------------------------
@@ -542,3 +557,4 @@ sub preprocess_paragraph {
     return  $self->SUPER::preprocess_paragraph($_);
 }
 
+1; # keep require happy