| 1 | #!/import/archperf/ws/devtools/4/amd64/bin/perl |
| 2 | eval 'exec perl -S $0 "$@"' |
| 3 | if 0; |
| 4 | |
| 5 | ############################################################################# |
| 6 | # podselect -- command to invoke the podselect function in Pod::Select |
| 7 | # |
| 8 | # Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved. |
| 9 | # This file is part of "PodParser". PodParser is free software; |
| 10 | # you can redistribute it and/or modify it under the same terms |
| 11 | # as Perl itself. |
| 12 | ############################################################################# |
| 13 | |
| 14 | use strict; |
| 15 | use diagnostics; |
| 16 | |
| 17 | =head1 NAME |
| 18 | |
| 19 | podselect - print selected sections of pod documentation on standard output |
| 20 | |
| 21 | =head1 SYNOPSIS |
| 22 | |
| 23 | B<podselect> [B<-help>] [B<-man>] [B<-section>S< >I<section-spec>] |
| 24 | [I<file>S< >...] |
| 25 | |
| 26 | =head1 OPTIONS AND ARGUMENTS |
| 27 | |
| 28 | =over 8 |
| 29 | |
| 30 | =item B<-help> |
| 31 | |
| 32 | Print a brief help message and exit. |
| 33 | |
| 34 | =item B<-man> |
| 35 | |
| 36 | Print the manual page and exit. |
| 37 | |
| 38 | =item B<-section>S< >I<section-spec> |
| 39 | |
| 40 | Specify a section to include in the output. |
| 41 | See L<Pod::Parser/"SECTION SPECIFICATIONS"> |
| 42 | for the format to use for I<section-spec>. |
| 43 | This option may be given multiple times on the command line. |
| 44 | |
| 45 | =item I<file> |
| 46 | |
| 47 | The pathname of a file from which to select sections of pod |
| 48 | documentation (defaults to standard input). |
| 49 | |
| 50 | =back |
| 51 | |
| 52 | =head1 DESCRIPTION |
| 53 | |
| 54 | B<podselect> will read the given input files looking for pod |
| 55 | documentation and will print out (in raw pod format) all sections that |
| 56 | match one ore more of the given section specifications. If no section |
| 57 | specifications are given than all pod sections encountered are output. |
| 58 | |
| 59 | B<podselect> invokes the B<podselect()> function exported by B<Pod::Select> |
| 60 | Please see L<Pod::Select/podselect()> for more details. |
| 61 | |
| 62 | =head1 SEE ALSO |
| 63 | |
| 64 | L<Pod::Parser> and L<Pod::Select> |
| 65 | |
| 66 | =head1 AUTHOR |
| 67 | |
| 68 | Please report bugs using L<http://rt.cpan.org>. |
| 69 | |
| 70 | Brad Appleton E<lt>bradapp@enteract.comE<gt> |
| 71 | |
| 72 | Based on code for B<Pod::Text::pod2text(1)> written by |
| 73 | Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> |
| 74 | |
| 75 | =cut |
| 76 | |
| 77 | use Pod::Select; |
| 78 | use Pod::Usage; |
| 79 | use Getopt::Long; |
| 80 | |
| 81 | ## Define options |
| 82 | my %options = ( |
| 83 | "help" => 0, |
| 84 | "man" => 0, |
| 85 | "sections" => [], |
| 86 | ); |
| 87 | |
| 88 | ## Parse options |
| 89 | GetOptions(\%options, "help", "man", "sections|select=s@") || pod2usage(2); |
| 90 | pod2usage(1) if ($options{help}); |
| 91 | pod2usage(-verbose => 2) if ($options{man}); |
| 92 | |
| 93 | ## Dont default to STDIN if connected to a terminal |
| 94 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); |
| 95 | |
| 96 | ## Invoke podselect(). |
| 97 | if (@{ $options{"sections"} } > 0) { |
| 98 | podselect({ -sections => $options{"sections"} }, @ARGV); |
| 99 | } |
| 100 | else { |
| 101 | podselect(@ARGV); |
| 102 | } |
| 103 | |
| 104 | |