Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Pod::Usage.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Pod::Usage 3"
132.TH Pod::Usage 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134Pod::Usage, pod2usage() \- print a usage message from embedded pod documentation
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use Pod::Usage
139.Ve
140.PP
141.Vb 4
142\& my $message_text = "This text precedes the usage message.";
143\& my $exit_status = 2; ## The exit status to use
144\& my $verbose_level = 0; ## The verbose level to use
145\& my $filehandle = \e*STDERR; ## The filehandle to write to
146.Ve
147.PP
148.Vb 1
149\& pod2usage($message_text);
150.Ve
151.PP
152.Vb 1
153\& pod2usage($exit_status);
154.Ve
155.PP
156.Vb 4
157\& pod2usage( { -message => $message_text ,
158\& -exitval => $exit_status ,
159\& -verbose => $verbose_level,
160\& -output => $filehandle } );
161.Ve
162.PP
163.Vb 4
164\& pod2usage( -msg => $message_text ,
165\& -exitval => $exit_status ,
166\& -verbose => $verbose_level,
167\& -output => $filehandle );
168.Ve
169.SH "ARGUMENTS"
170.IX Header "ARGUMENTS"
171\&\fBpod2usage\fR should be given either a single argument, or a list of
172arguments corresponding to an associative array (a \*(L"hash\*(R"). When a single
173argument is given, it should correspond to exactly one of the following:
174.IP "\(bu" 4
175A string containing the text of a message to print \fIbefore\fR printing
176the usage message
177.IP "\(bu" 4
178A numeric value corresponding to the desired exit status
179.IP "\(bu" 4
180A reference to a hash
181.PP
182If more than one argument is given then the entire argument list is
183assumed to be a hash. If a hash is supplied (either as a reference or
184as a list) it should contain one or more elements with the following
185keys:
186.ie n .IP """\-message""" 4
187.el .IP "\f(CW\-message\fR" 4
188.IX Item "-message"
189.PD 0
190.ie n .IP """\-msg""" 4
191.el .IP "\f(CW\-msg\fR" 4
192.IX Item "-msg"
193.PD
194The text of a message to print immediately prior to printing the
195program's usage message.
196.ie n .IP """\-exitval""" 4
197.el .IP "\f(CW\-exitval\fR" 4
198.IX Item "-exitval"
199The desired exit status to pass to the \fB\f(BIexit()\fB\fR function.
200This should be an integer, or else the string \*(L"\s-1NOEXIT\s0\*(R" to
201indicate that control should simply be returned without
202terminating the invoking process.
203.ie n .IP """\-verbose""" 4
204.el .IP "\f(CW\-verbose\fR" 4
205.IX Item "-verbose"
206The desired level of \*(L"verboseness\*(R" to use when printing the usage
207message. If the corresponding value is 0, then only the \*(L"\s-1SYNOPSIS\s0\*(R"
208section of the pod documentation is printed. If the corresponding value
209is 1, then the \*(L"\s-1SYNOPSIS\s0\*(R" section, along with any section entitled
210\&\*(L"\s-1OPTIONS\s0\*(R", \*(L"\s-1ARGUMENTS\s0\*(R", or \*(L"\s-1OPTIONS\s0 \s-1AND\s0 \s-1ARGUMENTS\s0\*(R" is printed. If the
211corresponding value is 2 or more then the entire manpage is printed.
212.ie n .IP """\-output""" 4
213.el .IP "\f(CW\-output\fR" 4
214.IX Item "-output"
215A reference to a filehandle, or the pathname of a file to which the
216usage message should be written. The default is \f(CW\*(C`\e*STDERR\*(C'\fR unless the
217exit value is less than 2 (in which case the default is \f(CW\*(C`\e*STDOUT\*(C'\fR).
218.ie n .IP """\-input""" 4
219.el .IP "\f(CW\-input\fR" 4
220.IX Item "-input"
221A reference to a filehandle, or the pathname of a file from which the
222invoking script's pod documentation should be read. It defaults to the
223file indicated by \f(CW$0\fR (\f(CW$PROGRAM_NAME\fR for users of \fIEnglish.pm\fR).
224.ie n .IP """\-pathlist""" 4
225.el .IP "\f(CW\-pathlist\fR" 4
226.IX Item "-pathlist"
227A list of directory paths. If the input file does not exist, then it
228will be searched for in the given directory list (in the order the
229directories appear in the list). It defaults to the list of directories
230implied by \f(CW$ENV{PATH}\fR. The list may be specified either by a reference
231to an array, or by a string of directory paths which use the same path
232separator as \f(CW$ENV{PATH}\fR on your system (e.g., \f(CW\*(C`:\*(C'\fR for Unix, \f(CW\*(C`;\*(C'\fR for
233MSWin32 and \s-1DOS\s0).
234.SH "DESCRIPTION"
235.IX Header "DESCRIPTION"
236\&\fBpod2usage\fR will print a usage message for the invoking script (using
237its embedded pod documentation) and then exit the script with the
238desired exit status. The usage message printed may have any one of three
239levels of \*(L"verboseness\*(R": If the verbose level is 0, then only a synopsis
240is printed. If the verbose level is 1, then the synopsis is printed
241along with a description (if present) of the command line options and
242arguments. If the verbose level is 2, then the entire manual page is
243printed.
244.PP
245Unless they are explicitly specified, the default values for the exit
246status, verbose level, and output stream to use are determined as
247follows:
248.IP "\(bu" 4
249If neither the exit status nor the verbose level is specified, then the
250default is to use an exit status of 2 with a verbose level of 0.
251.IP "\(bu" 4
252If an exit status \fIis\fR specified but the verbose level is \fInot\fR, then the
253verbose level will default to 1 if the exit status is less than 2 and
254will default to 0 otherwise.
255.IP "\(bu" 4
256If an exit status is \fInot\fR specified but verbose level \fIis\fR given, then
257the exit status will default to 2 if the verbose level is 0 and will
258default to 1 otherwise.
259.IP "\(bu" 4
260If the exit status used is less than 2, then output is printed on
261\&\f(CW\*(C`STDOUT\*(C'\fR. Otherwise output is printed on \f(CW\*(C`STDERR\*(C'\fR.
262.PP
263Although the above may seem a bit confusing at first, it generally does
264\&\*(L"the right thing\*(R" in most situations. This determination of the default
265values to use is based upon the following typical Unix conventions:
266.IP "\(bu" 4
267An exit status of 0 implies \*(L"success\*(R". For example, \fB\f(BIdiff\fB\|(1)\fR exits
268with a status of 0 if the two files have the same contents.
269.IP "\(bu" 4
270An exit status of 1 implies possibly abnormal, but non\-defective, program
271termination. For example, \fB\f(BIgrep\fB\|(1)\fR exits with a status of 1 if
272it did \fInot\fR find a matching line for the given regular expression.
273.IP "\(bu" 4
274An exit status of 2 or more implies a fatal error. For example, \fB\f(BIls\fB\|(1)\fR
275exits with a status of 2 if you specify an illegal (unknown) option on
276the command line.
277.IP "\(bu" 4
278Usage messages issued as a result of bad command-line syntax should go
279to \f(CW\*(C`STDERR\*(C'\fR. However, usage messages issued due to an explicit request
280to print usage (like specifying \fB\-help\fR on the command line) should go
281to \f(CW\*(C`STDOUT\*(C'\fR, just in case the user wants to pipe the output to a pager
282(such as \fB\f(BImore\fB\|(1)\fR).
283.IP "\(bu" 4
284If program usage has been explicitly requested by the user, it is often
285desireable to exit with a status of 1 (as opposed to 0) after issuing
286the user-requested usage message. It is also desireable to give a
287more verbose description of program usage in this case.
288.PP
289\&\fBpod2usage\fR doesn't force the above conventions upon you, but it will
290use them by default if you don't expressly tell it to do otherwise. The
291ability of \fB\f(BIpod2usage()\fB\fR to accept a single number or a string makes it
292convenient to use as an innocent looking error message handling function:
293.PP
294.Vb 2
295\& use Pod::Usage;
296\& use Getopt::Long;
297.Ve
298.PP
299.Vb 4
300\& ## Parse options
301\& GetOptions("help", "man", "flag1") || pod2usage(2);
302\& pod2usage(1) if ($opt_help);
303\& pod2usage(-verbose => 2) if ($opt_man);
304.Ve
305.PP
306.Vb 2
307\& ## Check for too many filenames
308\& pod2usage("$0: Too many files given.\en") if (@ARGV > 1);
309.Ve
310.PP
311Some user's however may feel that the above \*(L"economy of expression\*(R" is
312not particularly readable nor consistent and may instead choose to do
313something more like the following:
314.PP
315.Vb 2
316\& use Pod::Usage;
317\& use Getopt::Long;
318.Ve
319.PP
320.Vb 4
321\& ## Parse options
322\& GetOptions("help", "man", "flag1") || pod2usage(-verbose => 0);
323\& pod2usage(-verbose => 1) if ($opt_help);
324\& pod2usage(-verbose => 2) if ($opt_man);
325.Ve
326.PP
327.Vb 3
328\& ## Check for too many filenames
329\& pod2usage(-verbose => 2, -message => "$0: Too many files given.\en")
330\& if (@ARGV > 1);
331.Ve
332.PP
333As with all things in Perl, \fIthere's more than one way to do it\fR, and
334\&\fB\f(BIpod2usage()\fB\fR adheres to this philosophy. If you are interested in
335seeing a number of different ways to invoke \fBpod2usage\fR (although by no
336means exhaustive), please refer to \*(L"\s-1EXAMPLES\s0\*(R".
337.SH "EXAMPLES"
338.IX Header "EXAMPLES"
339Each of the following invocations of \f(CW\*(C`pod2usage()\*(C'\fR will print just the
340\&\*(L"\s-1SYNOPSIS\s0\*(R" section to \f(CW\*(C`STDERR\*(C'\fR and will exit with a status of 2:
341.PP
342.Vb 1
343\& pod2usage();
344.Ve
345.PP
346.Vb 1
347\& pod2usage(2);
348.Ve
349.PP
350.Vb 1
351\& pod2usage(-verbose => 0);
352.Ve
353.PP
354.Vb 1
355\& pod2usage(-exitval => 2);
356.Ve
357.PP
358.Vb 1
359\& pod2usage({-exitval => 2, -output => \e*STDERR});
360.Ve
361.PP
362.Vb 1
363\& pod2usage({-verbose => 0, -output => \e*STDERR});
364.Ve
365.PP
366.Vb 1
367\& pod2usage(-exitval => 2, -verbose => 0);
368.Ve
369.PP
370.Vb 1
371\& pod2usage(-exitval => 2, -verbose => 0, -output => \e*STDERR);
372.Ve
373.PP
374Each of the following invocations of \f(CW\*(C`pod2usage()\*(C'\fR will print a message
375of \*(L"Syntax error.\*(R" (followed by a newline) to \f(CW\*(C`STDERR\*(C'\fR, immediately
376followed by just the \*(L"\s-1SYNOPSIS\s0\*(R" section (also printed to \f(CW\*(C`STDERR\*(C'\fR) and
377will exit with a status of 2:
378.PP
379.Vb 1
380\& pod2usage("Syntax error.");
381.Ve
382.PP
383.Vb 1
384\& pod2usage(-message => "Syntax error.", -verbose => 0);
385.Ve
386.PP
387.Vb 1
388\& pod2usage(-msg => "Syntax error.", -exitval => 2);
389.Ve
390.PP
391.Vb 1
392\& pod2usage({-msg => "Syntax error.", -exitval => 2, -output => \e*STDERR});
393.Ve
394.PP
395.Vb 1
396\& pod2usage({-msg => "Syntax error.", -verbose => 0, -output => \e*STDERR});
397.Ve
398.PP
399.Vb 1
400\& pod2usage(-msg => "Syntax error.", -exitval => 2, -verbose => 0);
401.Ve
402.PP
403.Vb 4
404\& pod2usage(-message => "Syntax error.",
405\& -exitval => 2,
406\& -verbose => 0,
407\& -output => \e*STDERR);
408.Ve
409.PP
410Each of the following invocations of \f(CW\*(C`pod2usage()\*(C'\fR will print the
411\&\*(L"\s-1SYNOPSIS\s0\*(R" section and any \*(L"\s-1OPTIONS\s0\*(R" and/or \*(L"\s-1ARGUMENTS\s0\*(R" sections to
412\&\f(CW\*(C`STDOUT\*(C'\fR and will exit with a status of 1:
413.PP
414.Vb 1
415\& pod2usage(1);
416.Ve
417.PP
418.Vb 1
419\& pod2usage(-verbose => 1);
420.Ve
421.PP
422.Vb 1
423\& pod2usage(-exitval => 1);
424.Ve
425.PP
426.Vb 1
427\& pod2usage({-exitval => 1, -output => \e*STDOUT});
428.Ve
429.PP
430.Vb 1
431\& pod2usage({-verbose => 1, -output => \e*STDOUT});
432.Ve
433.PP
434.Vb 1
435\& pod2usage(-exitval => 1, -verbose => 1);
436.Ve
437.PP
438.Vb 1
439\& pod2usage(-exitval => 1, -verbose => 1, -output => \e*STDOUT});
440.Ve
441.PP
442Each of the following invocations of \f(CW\*(C`pod2usage()\*(C'\fR will print the
443entire manual page to \f(CW\*(C`STDOUT\*(C'\fR and will exit with a status of 1:
444.PP
445.Vb 1
446\& pod2usage(-verbose => 2);
447.Ve
448.PP
449.Vb 1
450\& pod2usage({-verbose => 2, -output => \e*STDOUT});
451.Ve
452.PP
453.Vb 1
454\& pod2usage(-exitval => 1, -verbose => 2);
455.Ve
456.PP
457.Vb 1
458\& pod2usage({-exitval => 1, -verbose => 2, -output => \e*STDOUT});
459.Ve
460.Sh "Recommended Use"
461.IX Subsection "Recommended Use"
462Most scripts should print some type of usage message to \f(CW\*(C`STDERR\*(C'\fR when a
463command line syntax error is detected. They should also provide an
464option (usually \f(CW\*(C`\-H\*(C'\fR or \f(CW\*(C`\-help\*(C'\fR) to print a (possibly more verbose)
465usage message to \f(CW\*(C`STDOUT\*(C'\fR. Some scripts may even wish to go so far as to
466provide a means of printing their complete documentation to \f(CW\*(C`STDOUT\*(C'\fR
467(perhaps by allowing a \f(CW\*(C`\-man\*(C'\fR option). The following complete example
468uses \fBPod::Usage\fR in combination with \fBGetopt::Long\fR to do all of these
469things:
470.PP
471.Vb 2
472\& use Getopt::Long;
473\& use Pod::Usage;
474.Ve
475.PP
476.Vb 7
477\& my $man = 0;
478\& my $help = 0;
479\& ## Parse options and print usage if there is a syntax error,
480\& ## or if usage was explicitly requested.
481\& GetOptions('help|?' => \e$help, man => \e$man) or pod2usage(2);
482\& pod2usage(1) if $help;
483\& pod2usage(-verbose => 2) if $man;
484.Ve
485.PP
486.Vb 4
487\& ## If no arguments were given, then allow STDIN to be used only
488\& ## if it's not connected to a terminal (otherwise print usage)
489\& pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN));
490\& __END__
491.Ve
492.PP
493.Vb 1
494\& =head1 NAME
495.Ve
496.PP
497.Vb 1
498\& sample - Using GetOpt::Long and Pod::Usage
499.Ve
500.PP
501.Vb 1
502\& =head1 SYNOPSIS
503.Ve
504.PP
505.Vb 1
506\& sample [options] [file ...]
507.Ve
508.PP
509.Vb 3
510\& Options:
511\& -help brief help message
512\& -man full documentation
513.Ve
514.PP
515.Vb 1
516\& =head1 OPTIONS
517.Ve
518.PP
519.Vb 1
520\& =over 8
521.Ve
522.PP
523.Vb 1
524\& =item B<-help>
525.Ve
526.PP
527.Vb 1
528\& Print a brief help message and exits.
529.Ve
530.PP
531.Vb 1
532\& =item B<-man>
533.Ve
534.PP
535.Vb 1
536\& Prints the manual page and exits.
537.Ve
538.PP
539.Vb 1
540\& =back
541.Ve
542.PP
543.Vb 1
544\& =head1 DESCRIPTION
545.Ve
546.PP
547.Vb 2
548\& B<This program> will read the given input file(s) and do something
549\& useful with the contents thereof.
550.Ve
551.PP
552.Vb 1
553\& =cut
554.Ve
555.SH "CAVEATS"
556.IX Header "CAVEATS"
557By default, \fB\f(BIpod2usage()\fB\fR will use \f(CW$0\fR as the path to the pod input
558file. Unfortunately, not all systems on which Perl runs will set \f(CW$0\fR
559properly (although if \f(CW$0\fR isn't found, \fB\f(BIpod2usage()\fB\fR will search
560\&\f(CW$ENV{PATH}\fR or else the list specified by the \f(CW\*(C`\-pathlist\*(C'\fR option).
561If this is the case for your system, you may need to explicitly specify
562the path to the pod docs for the invoking script using something
563similar to the following:
564.PP
565.Vb 1
566\& pod2usage(-exitval => 2, -input => "/path/to/your/pod/docs");
567.Ve
568.SH "AUTHOR"
569.IX Header "AUTHOR"
570Brad Appleton <bradapp@enteract.com>
571.PP
572Based on code for \fB\f(BIPod::Text::pod2text()\fB\fR written by
573Tom Christiansen <tchrist@mox.perl.com>
574.SH "ACKNOWLEDGEMENTS"
575.IX Header "ACKNOWLEDGEMENTS"
576Steven McDougall <swmcd@world.std.com> for his help and patience
577with re-writing this manpage.