.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Getopt::Euclid 3pm" .TH Getopt::Euclid 3pm "2015-06-08" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Getopt::Euclid \- Executable Uniform Command\-Line Interface Descriptions .SH "VERSION" .IX Header "VERSION" This document describes Getopt::Euclid version 0.4.5 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Getopt::Euclid; \& \& if ($ARGV{\-i}) { \& print "Interactive mode...\en"; \& } \& \& for my $x (0..$ARGV{\-size}{h}\-1) { \& for my $y (0..$ARGV{\-size}{w}\-1) { \& do_something_with($x, $y); \& } \& } \& \& _\|_END_\|_ \& \& =head1 NAME \& \& yourprog \- Your program here \& \& =head1 VERSION \& \& This documentation refers to yourprog version 1.9.4 \& \& =head1 USAGE \& \& yourprog [options] \-s[ize]=x \-o[ut][file] \& \& =head1 REQUIRED ARGUMENTS \& \& =over \& \& =item \-s[ize]=x \& \& Specify size of simulation \& \& =for Euclid: \& h.type: int > 0 \& h.default: 24 \& w.type: int >= 10 \& w.default: 80 \& \& =item \-o[ut][file] \& \& Specify output file \& \& =for Euclid: \& file.type: writable \& file.default: \*(Aq\-\*(Aq \& \& =back \& \& =head1 OPTIONS \& \& =over \& \& =item \-i \& \& Specify interactive simulation \& \& =item \-l[[en][gth]] \& \& Length of simulation. The default is l.default \& \& =for Euclid: \& l.type: int > 0 \& l.default: 99 \& \& =item \-\-debug [] \& \& Set the log level. Default is log_level.default but if you provide \-\-debug, \& then it is log_level.opt_default. \& \& =for Euclid: \& log_level.type: int \& log_level.default: 0 \& log_level.opt_default: 1 \& \& =item \-\-version \& \& =item \-\-usage \& \& =item \-\-help \& \& =item \-\-man \& \& Print the usual program information \& \& =back \& \& Remainder of documentation starts here... \& \& =head1 AUTHOR \& \& Damian Conway (DCONWAY@CPAN.org) \& \& =head1 BUGS \& \& There are undoubtedly serious bugs lurking somewhere in this code. \& Bug reports and other feedback are most welcome. \& \& =head1 COPYRIGHT \& \& Copyright (c) 2005, Damian Conway. All Rights Reserved. \& This module is free software. It may be used, redistributed \& and/or modified under the terms of the Perl Artistic License \& (see http://www.perl.com/perl/misc/Artistic.html) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Getopt::Euclid uses your program's own \s-1POD\s0 documentation to create a powerful command-line argument parser. This ensures that your program's documented interface and its actual interface always agree. .PP The created command-line argument parser includes many features such as argument type checking, required arguments, exclusive arguments, optional arguments with default values, automatic usage message, ... .PP To use the module, simply write the following at the top of your program: .PP .Vb 1 \& use Getopt::Euclid; .Ve .PP This will cause Getopt::Euclid to be require'd and its import method will be called. It is important that the import method be allowed to run, so do not invoke Getopt::Euclid in the following manner: .PP .Vb 2 \& # Will not work \& use Getopt::Euclid (); .Ve .PP When the module is loaded within a regular Perl program, it will: .IP "1." 4 locate any \s-1POD\s0 in the same *.pl file or its associated *.pod file. .IP "2." 4 extract information from that \s-1POD,\s0 most especially from the \f(CW\*(C`=head1 REQUIRED ARGUMENTS\*(C'\fR and \f(CW\*(C`=head1 OPTIONS\*(C'\fR sections, .IP "3." 4 build a parser that parses the arguments and options the \s-1POD\s0 specifies, .IP "4." 4 remove the command-line arguments from \f(CW@ARGV\fR and parse them, and .IP "5." 4 put the results in the global \f(CW%ARGV\fR variable (or into specifically named optional variables, if you request that \*(-- see \*(L"Exporting option variables\*(R"). .PP As a special case, if the module is loaded within some other module (i.e. from within a \f(CW\*(C`.pm\*(C'\fR file), it still locates and extracts \s-1POD\s0 information, but instead of parsing \f(CW@ARGV\fR immediately, it caches that information and installs an \f(CW\*(C`import()\*(C'\fR subroutine in the caller module. This new \f(CW\*(C`import()\*(C'\fR acts just like Getopt::Euclid's own import, except that it adds the \s-1POD\s0 from the caller module to the \s-1POD\s0 of the callee. .PP All of which just means you can put some or all of your \s-1CLI\s0 specification in a module, rather than in the application's source file. See \*(L"Module interface\*(R" for more details. .SH "INTERFACE" .IX Header "INTERFACE" .SS "Program interface" .IX Subsection "Program interface" You write: .PP .Vb 1 \& use Getopt::Euclid; .Ve .PP and your command-line is parsed automagically. .SS "Module interface" .IX Subsection "Module interface" .IP "\fIimport()\fR" 4 .IX Item "import()" You write: .Sp .Vb 1 \& use Getopt::Euclid; .Ve .Sp and your module will then act just like Getopt::Euclid (i.e. you can use your module \fIinstead\fR of Getopt::Euclid>, except that your module's \s-1POD\s0 will also be prepended to the \s-1POD\s0 of any module that loads yours. In other words, you can use Getopt::Euclid in a module to create a standard set of \s-1CLI\s0 arguments, which can then be added to any application simply by loading your module. .Sp To accomplish this trick Getopt::Euclid installs an \f(CW\*(C`import()\*(C'\fR subroutine in your module. If your module already has an \f(CW\*(C`import()\*(C'\fR subroutine defined, terrible things happen. So do not do that. .Sp You may also short-circuit the import method within your calling program to have the \s-1POD\s0 from several modules included for argument parsing. .Sp .Vb 3 \& use Module1::Getopt (); # No argument parsing \& use Module2::Getopt (); # No argument parsing \& use Getopt::Euclid; # Arguments parsed .Ve .IP "\fIprocess_args()\fR" 4 .IX Item "process_args()" Alternatively, to parse arguments from a source different from \f(CW@ARGV\fR, use the \&\f(CW\*(C`process_args()\*(C'\fR subroutine. .Sp .Vb 3 \& use Getopt::Euclid qw(:defer); \& my @args = ( \*(Aq\-in\*(Aq, \*(Aqfile.txt\*(Aq, \*(Aq\-out\*(Aq, \*(Aqresults.txt\*(Aq ); \& Getopt::Euclid\->process_args(\e@args); .Ve .Sp If you want to use the :minimal or :vars mode in this type of scenario, you can pass extra options to \f(CW\*(C`process_args()\*(C'\fR: .Sp .Vb 3 \& use Getopt::Euclid qw(:defer); \& my @args = ( \*(Aq\-in\*(Aq, \*(Aqfile.txt\*(Aq, \*(Aq\-out\*(Aq, \*(Aqresults.txt\*(Aq ); \& Getopt::Euclid\->process_args(\e@args, {\-minimal => 1, \-vars => \*(Aqprefix_\*(Aq}); .Ve .Sp This is particularly when you plan on processing \s-1POD\s0 manually. .IP "\fIprocess_pods()\fR" 4 .IX Item "process_pods()" Similarly, to parse argument specifications from a source different than the current script (and its dependencies), use the \f(CW\*(C`process_pods()\*(C'\fR subroutine. .Sp .Vb 5 \& use Getopt::Euclid (); \& my @pods = ( \*(Aqscript.pl\*(Aq, \*(AqModule.pm\*(Aq ); \& $Getopt::Euclid::MAN = Getopt::Euclid\->process_pods(\e@pods, {\-strict => 1}); \& my @args = ( \*(Aq\-in\*(Aq, \*(Aqfile.txt\*(Aq, \*(Aq\-out\*(Aq, \*(Aqresults.txt\*(Aq ); \& Getopt::Euclid\->process_args(\e@args); .Ve .Sp By default, this method will look for .pod files associated with the given .pl and .pm files and use these .pod files preferentially when available. Set \&\-strict to 1 to only use the given files. .SS "\s-1POD\s0 interface" .IX Subsection "POD interface" This is where all the action is. \s-1POD\s0 markup can be placed in a .pod file that has the same prefix as the corresponding Perl file. Alternatively, \s-1POD\s0 can be inserted anywhere in the Perl code, but is typically added either after an _\|_END_\|_ statement (like in the \s-1SYNOPSIS\s0), or interspersed in the code: .PP .Vb 1 \& use Getopt::Euclid; \& \& =head1 NAME \& \& yourprog \- Your program here \& \& =head1 REQUIRED ARGUMENTS \& \& =over \& \& =item \-s[ize]=x \& \& Specify size of simulation \& \& =for Euclid: \& h.type: int > 0 \& h.default: 24 \& w.type: int >= 10 \& w.default: 80 \& \& =back \& \& =head1 OPTIONS \& \& =over \& \& =item \-i \& \& Specify interactive simulation \& \& =back \& \& =cut \& \& # Getopt::Euclid has parsed commandline parameters and stored them in %ARGV \& \& if ($ARGV{\-i}) { \& print "Interactive mode...\en"; \& } \& \& for my $x (0..$ARGV{\-size}{h}\-1) { \& for my $y (0..$ARGV{\-size}{w}\-1) { \& do_something_with($x, $y); \& } \& } .Ve .PP When Getopt::Euclid is loaded in a non\-\f(CW\*(C`.pm\*(C'\fR file, it searches that file for the following \s-1POD\s0 documentation: .IP "=head1 \s-1NAME\s0" 4 .IX Item "=head1 NAME" Getopt::Euclid ignores the name specified here. In fact, if you use the standard \f(CW\*(C`\-\-help\*(C'\fR, \f(CW\*(C`\-\-usage\*(C'\fR, \f(CW\*(C`\-\-man\*(C'\fR, \f(CW\*(C`\-\-podfile\*(C'\fR, or \f(CW\*(C`\-\-version\*(C'\fR arguments (see \*(L"Standard arguments\*(R"), the module replaces the name specified in this \s-1POD\s0 section with the actual name by which the program was invoked (i.e. with \f(CW$0\fR). .IP "=head1 \s-1USAGE\s0" 4 .IX Item "=head1 USAGE" Getopt::Euclid ignores the usage line specified here. If you use the standard \f(CW\*(C`\-\-help\*(C'\fR, \f(CW\*(C`\-\-usage\*(C'\fR, \f(CW\*(C`\-\-man\*(C'\fR or \f(CW\*(C`\-\-podfile\*(C'\fR arguments, the module replaces the usage line specified in this \s-1POD\s0 section with a usage line that reflects the actual interface that the module has constructed. .IP "=head1 \s-1VERSION\s0" 4 .IX Item "=head1 VERSION" Getopt::Euclid extracts the current version number from this \s-1POD\s0 section. To do that it simply takes the first substring that matches \&\fI\fR.\fI\fR or \fI\fR_\fI\fR. It also accepts one or more additional trailing .\fI\fR or _\fI\fR, allowing for multi-level and \*(L"alpha\*(R" version numbers such as: .Sp .Vb 1 \& =head1 VERSION \& \& This is version 1.2.3 .Ve .Sp or: .Sp .Vb 1 \& =head1 VERSION \& \& This is alpha release 1.2_34 .Ve .Sp You may also specify the version number in your code. However, in order for Getopt::Euclid to properly read it, it must be in a \f(CW\*(C`BEGIN\*(C'\fR block: .Sp .Vb 2 \& BEGIN { use version; our $VERSION = qv(\*(Aq1.2.3\*(Aq) } \& use Getopt::Euclid; .Ve .Sp Euclid stores the version as \f(CW$Getopt::Euclid::SCRIPT_VERSION\fR. .IP "=head1 \s-1REQUIRED ARGUMENTS\s0" 4 .IX Item "=head1 REQUIRED ARGUMENTS" Getopt::Euclid uses the specifications in this \s-1POD\s0 section to build a parser for command-line arguments. That parser requires that every one of the specified arguments is present in any command-line invocation. See \*(L"Specifying arguments\*(R" for details of the specification syntax. .Sp The actual headings that Getopt::Euclid can recognize here are: .Sp .Vb 1 \& =head1 [STANDARD|STD|PROGRAM|SCRIPT|CLI|COMMAND[\-| ]LINE] [REQUIRED|MANDATORY] [PARAM|PARAMETER|ARG|ARGUMENT][S] .Ve .Sp \&\fBCaveat:\fR Do not put additional subheadings (=headX) inside the \s-1REQUIRED ARGUMENTS\s0 section. .IP "=head1 \s-1OPTIONS\s0" 4 .IX Item "=head1 OPTIONS" Getopt::Euclid uses the specifications in this \s-1POD\s0 section to build a parser for command-line arguments. That parser does not require that any of the specified arguments is actually present in a command-line invocation. Again, see \*(L"Specifying arguments\*(R" for details of the specification syntax. .Sp Typically a program will specify both \f(CW\*(C`REQUIRED ARGUMENTS\*(C'\fR and \f(CW\*(C`OPTIONS\*(C'\fR, but there is no requirement that it supply both, or either. .Sp The actual headings that Getopt::Euclid recognizes here are: .Sp .Vb 1 \& =head1 [STANDARD|STD|PROGRAM|SCRIPT|CLI|COMMAND[\-| ]LINE] OPTION[AL|S] [PARAM|PARAMETER|ARG|ARGUMENT][S] .Ve .Sp \&\fBCaveat:\fR Do not put additional subheadings (=headX) inside the \s-1REQUIRED ARGUMENTS\s0 section. .IP "=head1 \s-1COPYRIGHT\s0" 4 .IX Item "=head1 COPYRIGHT" Getopt::Euclid prints this section whenever the standard \f(CW\*(C`\-\-version\*(C'\fR option is specified on the command-line. .Sp The actual heading that Getopt::Euclid recognizes here is any heading containing any of the words \*(L"\s-1COPYRIGHT\*(R", \*(L"LICENCE\*(R",\s0 or \*(L"\s-1LICENSE\*(R".\s0 .SS "Specifying arguments" .IX Subsection "Specifying arguments" Each required or optional argument is specified in the \s-1POD\s0 in the following format: .PP .Vb 1 \& =item ARGUMENT_STRUCTURE \& \& ARGUMENT_DESCRIPTION \& \& =for Euclid: \& ARGUMENT_OPTIONS \& PLACEHOLDER_CONSTRAINTS .Ve .PP \fIArgument structure\fR .IX Subsection "Argument structure" .IP "\(bu" 4 Each argument is specified as an \f(CW\*(C`=item\*(C'\fR. .IP "\(bu" 4 Any part(s) of the specification that appear in square brackets are treated as optional. .IP "\(bu" 4 Any parts that appear in angle brackets are placeholders for actual values that must be specified on the command-line. .IP "\(bu" 4 Any placeholder that is immediately followed by \f(CW\*(C`...\*(C'\fR may be repeated as many times as desired. .IP "\(bu" 4 Any whitespace in the structure specifies that any amount of whitespace (including none) is allowed at the same position on the command-line. .IP "\(bu" 4 A vertical bar indicates the start of an alternative variant of the argument. .PP For example, the argument specification: .PP .Vb 1 \& =item \-i[n] [=] | \-\-from .Ve .PP indicates that any of the following may appear on the command-line: .PP .Vb 1 \& \-idata.txt \-i data.txt \-i=data.txt \-i = data.txt \& \& \-indata.txt \-in data.txt \-in=data.txt \-in = data.txt \& \& \-\-from data.text .Ve .PP as well as any other combination of whitespacing. .PP Any of the above variations would cause all three of: .PP .Vb 3 \& $ARGV{\*(Aq\-i\*(Aq} \& $ARGV{\*(Aq\-in\*(Aq} \& $ARGV{\*(Aq\-\-from\*(Aq} .Ve .PP to be set to the string \f(CW\*(Aqdata.txt\*(Aq\fR. .PP You could allow the optional \f(CW\*(C`=\*(C'\fR to also be an optional colon by specifying: .PP .Vb 1 \& =item \-i[n] [=|:] .Ve .PP Optional components may also be nested, so you could write: .PP .Vb 1 \& =item \-i[n[put]] [=] .Ve .PP which would allow \f(CW\*(C`\-i\*(C'\fR, \f(CW\*(C`\-in\*(C'\fR, and \f(CW\*(C`\-input\*(C'\fR as synonyms for this argument and would set all three of \f(CW$ARGV{\*(Aq\-i\*(Aq}\fR, \f(CW$ARGV{\*(Aq\-in\*(Aq}\fR, and \&\f(CW$ARGV{\*(Aq\-input\*(Aq}\fR to the supplied file name. .PP The point of setting every possible variant within \f(CW%ARGV\fR is that this allows you to use a single key (say \f(CW$ARGV{\*(Aq\-input\*(Aq}\fR, regardless of how the argument is actually specified on the command-line. .SS "Repeatable arguments" .IX Subsection "Repeatable arguments" Normally Getopt::Euclid only accepts each specified argument once, the first time it appears in \f(CW@ARGV\fR. However, you can specify that an argument may appear more than once, using the \f(CW\*(C`repeatable\*(C'\fR option: .PP .Vb 1 \& =item file= \& \& =for Euclid: \& repeatable .Ve .PP When an argument is marked repeatable the corresponding entry of \f(CW%ARGV\fR will not contain a single value, but rather an array reference. If the argument also has \*(L"Multiple placeholders\*(R", then the corresponding entry in \f(CW%ARGV\fR will be an array reference with each array entry being a hash reference. .SS "Boolean arguments" .IX Subsection "Boolean arguments" If an argument has no placeholders it is treated as a boolean switch and its entry in \f(CW%ARGV\fR will be true if the argument appeared in \f(CW@ARGV\fR. .PP For a boolean argument, you can also specify variations that are \fIfalse\fR, if they appear. For example, a common idiom is: .PP .Vb 1 \& =item \-\-print \& \& Print results \& \& =item \-\-noprint \& \& Do not print results .Ve .PP These two arguments are effectively the same argument, just with opposite boolean values. However, as specified above, only one of \f(CW$ARGV{\*(Aq\-\-print\*(Aq}\fR and \f(CW$ARGV{\*(Aq\-\-noprint\*(Aq}\fR will be set. .PP As an alternative you can specify a single argument that accepts either value and sets both appropriately: .PP .Vb 1 \& =item \-\-[no]print \& \& [Do not] print results \& \& =for Euclid: \& false: \-\-noprint .Ve .PP With this specification, if \f(CW\*(C`\-\-print\*(C'\fR appears in \f(CW@ARGV\fR, then \&\f(CW$ARGV{\*(Aq\-\-print\*(Aq}\fR will be true and \f(CW$ARGV{\*(Aq\-\-noprint\*(Aq}\fR will be false. On the other hand, if \f(CW\*(C`\-\-noprint\*(C'\fR appears in \f(CW@ARGV\fR, then \&\f(CW$ARGV{\*(Aq\-\-print\*(Aq}\fR will be false and \f(CW$ARGV{\*(Aq\-\-noprint\*(Aq}\fR will be true. .PP The specified false values can follow any convention you wish: .PP .Vb 1 \& =item [+|\-]print \& \& =for Euclid: \& false: \-print .Ve .PP or: .PP .Vb 1 \& =item \-report[_no[t]] \& \& =for Euclid: \& false: \-report_no[t] .Ve .PP et cetera. .SS "Multiple placeholders" .IX Subsection "Multiple placeholders" An argument can have two or more placeholders: .PP .Vb 1 \& =item \-size .Ve .PP The corresponding command line argument would then have to provide two values: .PP .Vb 1 \& \-size 24 80 .Ve .PP Multiple placeholders can optionally be separated by literal characters (which must then appear on the command-line). For example: .PP .Vb 1 \& =item \-size x .Ve .PP would then require a command-line of the form: .PP .Vb 1 \& \-size 24x80 .Ve .PP If an argument has two or more placeholders, the corresponding entry in \&\f(CW%ARGV\fR becomes a hash reference, with each of the placeholder names as one key. That is, the above command-line would set both \f(CW$ARGV{\*(Aq\-size\*(Aq}{\*(Aqh\*(Aq}\fR and \&\f(CW$ARGV{\*(Aq\-size\*(Aq}{\*(Aqw\*(Aq}\fR. .SS "Optional placeholders" .IX Subsection "Optional placeholders" Placeholders can be specified as optional as well: .PP .Vb 1 \& =item \-size [] .Ve .PP This specification then allows either: .PP .Vb 1 \& \-size 24 .Ve .PP or: .PP .Vb 1 \& \-size 24 80 .Ve .PP on the command-line. If the second placeholder value is not provided, the corresponding \f(CW$ARGV{\*(Aq\-size\*(Aq}{\*(Aqw\*(Aq}\fR entry is set to \f(CW\*(C`undef\*(C'\fR. See also \&\*(L"Placeholder defaults\*(R". .SS "Unflagged placeholders" .IX Subsection "Unflagged placeholders" If an argument consists of a single placeholder with no \*(L"flag\*(R" marking it: .PP .Vb 1 \& =item .Ve .PP then the corresponding entry in \f(CW%ARG\fR will have a key the same as the placeholder (including the surrounding angle brackets): .PP .Vb 3 \& if ($ARGV{\*(Aq\*(Aq} eq \*(Aq\-\*(Aq) { \& $fh = \e*STDIN; \& } .Ve .PP The same is true for any more-complicated arguments that begin with a placeholder: .PP .Vb 1 \& =item [x ] .Ve .PP The only difference in the more-complex cases is that, if the argument has any additional placeholders, the entire entry in \f(CW%ARGV\fR becomes a hash: .PP .Vb 2 \& my $total_size \& = $ARGV{\*(Aq\*(Aq}{\*(Aqh\*(Aq} * $ARGV{\*(Aq\*(Aq}{\*(Aqw\*(Aq} .Ve .PP Note that, as in earlier multi-placeholder examples, the individual second\- level placeholder keys \fIdo not\fR retain their angle-brackets. .SS "Repeated placeholders" .IX Subsection "Repeated placeholders" Any placeholder that is immediately followed by \f(CW\*(C`...\*(C'\fR, like so: .PP .Vb 1 \& =item \-lib ... \& \& =for Euclid: \& file.type: readable .Ve .PP will match at least once, but as many times as possible before encountering the next argument on the command-line. This allows one to specify multiple values for an argument, for example: .PP .Vb 1 \& \-lib file1.txt file2.txt .Ve .PP An unconstrained repeated unflagged placeholder (see \*(L"Placeholder constraints\*(R" and \*(L"Unflagged placeholders\*(R") will consume the rest of the command-line, and so should be specified last in the \s-1POD\s0 .PP .Vb 1 \& =item \-n \& \& =item ... \& \& =for Euclid: \& offset.type: 0+int .Ve .PP and on the command-line: .PP .Vb 1 \& \-n foobar 1 5 0 23 .Ve .PP If a placeholder is repeated, the corresponding entry in \f(CW%ARGV\fR will then be an array reference, with each individual placeholder match in a separate element. For example: .PP .Vb 3 \& for my $lib (@{ $ARGV{\*(Aq\-lib\*(Aq} }) { \& add_lib($lib); \& } \& \& warn "First offset is: $ARGV{\*(Aq\*(Aq}[0]"; \& my $first_offset = shift @{ $ARGV{\*(Aq\*(Aq} }; .Ve .SS "Placeholder constraints" .IX Subsection "Placeholder constraints" You can specify that the value provided for a particular placeholder must satisfy a particular set of restrictions by using a \f(CW\*(C`=for Euclid\*(C'\fR block. For example: .PP .Vb 1 \& =item \-size x \& \& =for Euclid: \& h.type: integer \& w.type: integer .Ve .PP specifies that both the \f(CW\*(C`\*(C'\fR and \f(CW\*(C`\*(C'\fR must be given integers. You can also specify an operator expression after the type name: .PP .Vb 3 \& =for Euclid: \& h.type: integer > 0 \& w.type: number <= 100 .Ve .PP specifies that \f(CW\*(C`\*(C'\fR has to be given an integer that is greater than zero, and that \f(CW\*(C`\*(C'\fR has to be given a number (not necessarily an integer) that is no more than 100. .PP These type constraints have two alternative syntaxes: .PP .Vb 1 \& PLACEHOLDER.type: TYPE BINARY_OPERATOR EXPRESSION .Ve .PP as shown above, and the more general: .PP .Vb 1 \& PLACEHOLDER.type: TYPE [, EXPRESSION_INVOLVING(PLACEHOLDER)] .Ve .PP Using the second syntax, you could write the previous constraints as: .PP .Vb 3 \& =for Euclid: \& h.type: integer, h > 0 \& w.type: number, w <= 100 .Ve .PP In other words, the first syntax is just sugar for the most common case of the second syntax. The expression can be as complex as you wish and can refer to the placeholder as many times as necessary: .PP .Vb 3 \& =for Euclid: \& h.type: integer, h > 0 && h < 100 \& w.type: number, Math::is_prime(w) || w % 2 == 0 .Ve .PP Note that the expressions are evaluated in the \f(CW\*(C`package main\*(C'\fR namespace, so it is important to qualify any subroutines that are not in that namespace. Furthermore, any subroutines used must be defined (or loaded from a module) \&\fIbefore\fR the \f(CW\*(C`use Getopt::Euclid\*(C'\fR statement. .PP You can also use constraints that involve variables. You must use the :defer mode and the variables must be globally accessible: .PP .Vb 3 \& use Getopt::Euclid qw(:defer); \& our $MIN_VAL = 100; \& Getopt::Euclid\->process_args(\e@ARGV); \& \& _\|_END_\|_ \& \& =head1 OPTIONS \& \& =over \& \& =item \-\-magnitude \& \& =for Euclid \& magnitude.type: number, magnitude > $MIN_VAL \& \& =back .Ve .SS "Standard placeholder types" .IX Subsection "Standard placeholder types" Getopt::Euclid recognizes the following standard placeholder types: .PP .Vb 2 \& Name Placeholder value... Synonyms \& ============ ==================== ================ \& \& integer ...must be an integer int i \& \& +integer ...must be a positive +int +i \& integer \& (same as: integer > 0) \& \& 0+integer ...must be a positive 0+int 0+i \& integer or zero \& (same as: integer >= 0) \& \& number ...must be an number num n \& \& +number ...must be a positive +num +n \& number \& (same as: number > 0) \& \& 0+number ...must be a positive 0+num 0+n \& number or zero \& (same as: number >= 0) \& \& string ...may be any string str s \& (default type) \& \& readable ...must be the name input in \& of a readable file \& \& writeable ...must be the name writable output out \& of a writeable file \& (or of a non\-existent \& file in a writeable \& directory) \& \& // ...must be a string \& matching the specified \& pattern .Ve .PP Since regular expressions are supported, you can easily match many more type of strings for placeholders by using the regular expressions available in Regexp::Common. If you do that, you may want to also use custom placeholder error messages (see \&\*(L"Placeholder type errors\*(R") since the messages would otherwise not be very informative to users. .PP .Vb 2 \& use Regexp::Common qw /zip/; \& use Getopt::Euclid; \& \& ... \& \& =item \-p \& \& Enter your postcode here \& \& =for Euclid: \& postcode.type: /$RE{zip}{France}/ \& postcode.type.error: must be a valid ZIP code .Ve .SS "Placeholder type errors" .IX Subsection "Placeholder type errors" If a command-line argument's placeholder value does not satisify the specified type, an error message is automatically generated. However, you can provide your own message instead, using the \f(CW\*(C`.type.error\*(C'\fR specifier: .PP .Vb 3 \& =for Euclid: \& h.type: integer, h > 0 && h < 100 \& h.type.error: must be between 0 and 100 (not h) \& \& w.type: number, Math::is_prime(w) || w % 2 == 0 \& w.type.error: Cannot use w for (must be an even prime number) .Ve .PP Whenever an explicit error message is provided, any occurrence within the message of the placeholder's unbracketed name is replaced by the placeholder's value (just as in the type test itself). .SS "Placeholder defaults" .IX Subsection "Placeholder defaults" You can also specify a default value for any placeholders that are not given values on the command-line (either because their argument is not provided at all, or because the placeholder is optional within the argument). For example: .PP .Vb 1 \& =item \-size [x] \& \& Set the size of the simulation \& \& =for Euclid: \& h.default: 24 \& w.default: 80 .Ve .PP This ensures that if no \f(CW\*(C`\*(C'\fR value is supplied: .PP .Vb 1 \& \-size 20 .Ve .PP then \f(CW$ARGV{\*(Aq\-size\*(Aq}{\*(Aqw\*(Aq}\fR is set to 80. Likewise, of the \f(CW\*(C`\-size\*(C'\fR argument is omitted entirely, both \f(CW$ARGV{\*(Aq\-size\*(Aq}{\*(Aqh\*(Aq}\fR and \f(CW$ARGV{\*(Aq\-size\*(Aq}{\*(Aqw\*(Aq}\fR are set to their respective default values .PP However, Getopt::Euclid also supports a second type of default, optional defaults, that apply only to flagged, optional placeholders. .PP For example: .PP .Vb 1 \& =item \-\-debug [] \& \& Set the log level \& \& =for Euclid: \& log_level.type: int \& log_level.default: 0 \& log_level.opt_default: 1 .Ve .PP This ensures that if the option \f(CW\*(C`\-\-debug\*(C'\fR is not specified, then \&\f(CW$ARGV{\*(Aq\-\-debug\*(Aq}\fR is set to 0, the regular default. But if no \f(CW\*(C`\*(C'\fR value is supplied: .PP .Vb 1 \& \-\-debug .Ve .PP then \f(CW$ARGV{\*(Aq\-\-debug\*(Aq}\fR is set to 1, the optional default. .PP The default value can be any valid Perl compile-time expression: .PP .Vb 1 \& =item \-pi= \& \& =for Euclid: \& pi value.default: atan2(0,\-1) .Ve .PP You can refer to an argument default or optional default value in its \s-1POD\s0 entry as shown below: .PP .Vb 1 \& =item \-size [x] \& \& Set the size of the simulation [default: h.default x w.default] \& \& =for Euclid: \& h.default: 24 \& w.default: 80 \& \& =item \-\-debug \& \& Set the debug level. The default is level.default if you supply \-\-debug but \& omit a value. \& \& =for Euclid: \& level.opt_default: 3 .Ve .PP Just like for \*(L"Placeholder constraints\*(R", you can also use variables to define default values. You must use the :defer mode and the variables must be globally accessible: .PP .Vb 2 \& use Getopt::Euclid qw(:defer); \& Getopt::Euclid\->process_args(\e@ARGV); \& \& _\|_END_\|_ \& \& =head1 OPTIONS \& \& =over \& \& =item \-\-home \& \& Your project home. When omitted, this defaults to the location stored in \& the HOME environment variable. \& \& =for Euclid \& home.default: $ENV{\*(AqHOME\*(Aq} \& \& =back .Ve .SS "Exclusive placeholders" .IX Subsection "Exclusive placeholders" Some arguments can be mutually exclusive. In this case, it is possible to specify that a placeholder excludes a list of other placeholders, for example: .PP .Vb 1 \& =item \-height \& \& Set the desired height \& \& =item \-width \& \& Set the desired width \& \& =item \-volume \& \& Set the desired volume \& \& =for Euclid: \& v.excludes: h, w \& v.excludes.error: Either set the volume or the height and weight .Ve .PP Specifying both placeholders at the same time on the command-line will generate an error. Note that the error message can be customized, as illustrated above. .PP When using exclusive arguments that have default values, the default value of the placeholder with the .excludes statement has precedence over any other placeholders. .SS "Argument cuddling" .IX Subsection "Argument cuddling" Getopt::Euclid allows any \*(L"flag\*(R" argument to be \*(L"cuddled\*(R". A flag argument consists of a single non\- alphanumeric character, followed by a single alpha-numeric character: .PP .Vb 1 \& =item \-v \& \& =item \-x \& \& =item +1 \& \& =item =z .Ve .PP Cuddling means that two or more such arguments can be concatenated after a single common non-alphanumeric. For example: .PP .Vb 1 \& \-vx .Ve .PP Note, however, that only flags with the same leading non-alphanumeric can be cuddled together. Getopt::Euclid would not allow: .PP .Vb 1 \& \-vxz .Ve .PP This is because cuddling is recognized by progressively removing the second character of the cuddle. In other words: .PP .Vb 1 \& \-vxz .Ve .PP becomes: .PP .Vb 1 \& \-v \-xz .Ve .PP which becomes: .PP .Vb 1 \& \-v \-x z .Ve .PP which will fail, unless a \f(CW\*(C`z\*(C'\fR argument has also been specified. .PP On the other hand, if the argument: .PP .Vb 1 \& =item \-e .Ve .PP had been specified, the module \fIwould\fR accept: .PP .Vb 1 \& \-vxe\*(Aqprint time\*(Aq .Ve .PP as a cuddled version of: .PP .Vb 1 \& \-v \-x \-e\*(Aqprint time\*(Aq .Ve .SS "Exporting option variables" .IX Subsection "Exporting option variables" By default, the module only stores arguments into the global \f(CW%ARGV\fR hash. You can request that options are exported as variables into the calling package using the special \f(CW\*(Aq:vars\*(Aq\fR specifier: .PP .Vb 1 \& use Getopt::Euclid qw( :vars ); .Ve .PP That is, if your program accepts the following arguments: .PP .Vb 8 \& \-v \& \-\-mode \& \& \& \-\-auto\-fudge (repeatable) \& \-\-also ... \& \-\-size x \& \-\-multiply x (repeatable) .Ve .PP Then these variables will be exported .PP .Vb 8 \& $ARGV_v \& $ARGV_mode \& $ARGV_infile \& $ARGV_outfile \& @ARGV_auto_fudge \& @ARGV_also \& %ARGV_size # With entries $ARGV_size{w} and $ARGV_size{h} \& @ARGV_multiply # With entries that are hashref similar to \e%ARGV_size .Ve .PP For options that have multiple variants, only the longest variant is exported. .PP The type of variable exported (scalar, hash, or array) is determined by the type of the corresponding value in \f(CW%ARGV\fR. Command-line flags and arguments that take single values will produce scalars, arguments that take multiple values will produce hashes, and repeatable arguments will produce arrays. .PP If you do not like the default prefix of \*(L"\s-1ARGV_\*(R",\s0 you can specify your own, such as \*(L"opt_\*(R", like this: .PP .Vb 1 \& use Getopt::Euclid qw( :vars ); .Ve .PP The major advantage of using exported variables is that any misspelling of argument variables in your code will be caught at compile-time by \&\f(CW\*(C`use strict\*(C'\fR. .SS "Standard arguments" .IX Subsection "Standard arguments" Getopt::Euclid automatically provides four standard arguments to any program that uses the module. The behaviours of these arguments are \*(L"hard\- wired\*(R" and cannot be changed, not even by defining your own arguments of the same name. .PP The standard arguments are: .IP "\-\-usage \fIusage()\fR" 4 .IX Item "--usage usage()" The \-\-usage argument causes the program to print a short usage summary and exit. The \f(CW\*(C`Getopt::Euclid\-\*(C'\fR\fIusage()\fR> subroutine provides access to the string of this message. .IP "\-\-help \fIhelp()\fR" 4 .IX Item "--help help()" The \-\-help argument causes the program to take a longer usage summary (with a full list of required and optional arguments) provided in \s-1POD\s0 format by \&\f(CW\*(C`help()\*(C'\fR, convert it to plaintext, display it and exit. The message is paged using IO::Pager::Page (or IO::Page) if possible. .IP "\-\-man \fIman()\fR" 4 .IX Item "--man man()" The \-\-man argument causes the program to take the \s-1POD\s0 documentation for the program, provided by \f(CW\*(C`man()\*(C'\fR, convert it to plaintext, display it and exit. The message is paged using IO::Pager::Page (or IO::Page) if possible. .IP "\-\-podfile \fIpodfile()\fR" 4 .IX Item "--podfile podfile()" The \-\-podfile argument is provided for authors. It causes the program to take the \s-1POD\s0 manual from \f(CW\*(C`man()\*(C'\fR, write it in a .pod file with the same base name as the program, display the name of the output file and exit. These actions can also be executed by calling the \f(CW\*(C`podfile()\*(C'\fR subroutine.This argument is not really a standard argument, but it is useful if the program's \s-1POD\s0 is to be passed to a \s-1POD\s0 converter because, among other things, any default value specified is interpolated and replaced by its value in the .pod file, contrary to in the program's .pl file. .Sp If you want to automate the creation of a \s-1POD\s0 file during the build process, you can edit you Makefile.PL or Build.PL file and add these lines: .Sp .Vb 2 \& my @args = ($^X, \*(Aq\-Ilib\*(Aq, \*(Aq/path/to/script\*(Aq, \*(Aq\-\-podfile\*(Aq); \& system(@args) == 0 or die "System call to \*(Aq@args\*(Aq failed:\en$?\en"; .Ve .Sp If you use Module::Install to bundle your script, you might be interested in using Module::Install::PodFromEuclid to include the \-\-podfile step into the installation process. .IP "\-\-version \fIversion()\fR" 4 .IX Item "--version version()" The \-\-version argument causes the program to print the version number of the program (as specified in the \f(CW\*(C`=head1 VERSION\*(C'\fR section of the \s-1POD\s0) and any copyright information (as specified in the \f(CW\*(C`=head1 COPYRIGHT\*(C'\fR \&\s-1POD\s0 section) and then exit. The \f(CW\*(C`Getopt::Euclid\-\*(C'\fR\fIversion()\fR> subroutine provides access to the string of this message. .SS "Minimalist keys" .IX Subsection "Minimalist keys" By default, the keys of \f(CW%ARGV\fR will match the program's interface exactly. That is, if your program accepts the following arguments: .PP .Vb 5 \& \-v \& \-\-mode \& \& \& \-\-auto\-fudge .Ve .PP Then the keys that appear in \f(CW%ARGV\fR will be: .PP .Vb 5 \& \*(Aq\-v\*(Aq \& \*(Aq\-\-mode\*(Aq \& \*(Aq\*(Aq \& \*(Aq\*(Aq \& \*(Aq\-\-auto\-fudge\*(Aq .Ve .PP In some cases, however, it may be preferable to have Getopt::Euclid set up those hash keys without \*(L"decorations\*(R". That is, to have the keys of \&\f(CW%ARGV\fR be simply: .PP .Vb 5 \& \*(Aqv\*(Aq \& \*(Aqmode\*(Aq \& \*(Aqinfile\*(Aq \& \*(Aqoutfile\*(Aq \& \*(Aqauto_fudge\*(Aq .Ve .PP You can arrange this by loading the module with the special \f(CW\*(Aq:minimal_keys\*(Aq\fR specifier: .PP .Vb 1 \& use Getopt::Euclid qw( :minimal_keys ); .Ve .PP Note that, in rare cases, using this mode may cause you to lose data (for example, if the interface specifies both a \f(CW\*(C`\-\-step\*(C'\fR and a \f(CW\*(C`\*(C'\fR option). The module throws an exception if this happens. .SS "Deferring argument parsing" .IX Subsection "Deferring argument parsing" In some instances, you may want to avoid the parsing of arguments to take place as soon as your program is executed and Getopt::Euclid is loaded. For example, you may need to examine \f(CW@ARGV\fR before it is processed (and emptied) by Getopt::Euclid. Or you may intend to pass your own arguments manually only using \f(CW\*(C`process_args()\*(C'\fR. .PP To defer the parsing of arguments, use the specifier \f(CW\*(Aq:defer\*(Aq\fR: .PP .Vb 3 \& use Getopt::Euclid qw( :defer ); \& # Do something... \& Getopt::Euclid\->process_args(\e@ARGV); .Ve .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .SS "Compile-time diagnostics" .IX Subsection "Compile-time diagnostics" The following diagnostics are mainly caused by problems in the \s-1POD\s0 specification of the command-line interface: .IP "Getopt::Euclid was unable to access \s-1POD\s0" 4 .IX Item "Getopt::Euclid was unable to access POD" Something is horribly wrong. Getopt::Euclid was unable to read your program to extract the \s-1POD\s0 from it. Check your program's permissions, though it is a mystery how \fIperl\fR was able to run the program in the first place, if it is not readable. .IP ".pm file cannot define an explicit \fIimport()\fR when using Getopt::Euclid" 4 .IX Item ".pm file cannot define an explicit import() when using Getopt::Euclid" You tried to define an \f(CW\*(C`import()\*(C'\fR subroutine in a module that was also using Getopt::Euclid. Since the whole point of using Getopt::Euclid in a module is to have it build an \f(CW\*(C`import()\*(C'\fR for you, supplying your own \&\f(CW\*(C`import()\*(C'\fR as well defeats the purpose. .ie n .IP "Unknown specification: %s" 4 .el .IP "Unknown specification: \f(CW%s\fR" 4 .IX Item "Unknown specification: %s" You specified something in a \f(CW\*(C`=for Euclid\*(C'\fR section that Getopt::Euclid did not understand. This is often caused by typos, or by reversing a \fIplaceholder\fR.\fItype\fR or \fIplaceholder\fR.\fIdefault\fR specification (that is, writing \fItype\fR.\fIplaceholder\fR or \&\fIdefault\fR.\fIplaceholder\fR instead). .ie n .IP "Unknown type (%s) in specification: %s" 4 .el .IP "Unknown type (%s) in specification: \f(CW%s\fR" 4 .IX Item "Unknown type (%s) in specification: %s" .PD 0 .ie n .IP "Unknown .type constraint: %s" 4 .el .IP "Unknown .type constraint: \f(CW%s\fR" 4 .IX Item "Unknown .type constraint: %s" .PD Both these errors mean that you specified a type constraint that Getopt::Euclid did not recognize. This may have been a typo: .Sp .Vb 2 \& =for Euclid \& count.type: inetger .Ve .Sp or else the module simply does not know about the type you specified: .Sp .Vb 2 \& =for Euclid \& count.type: complex .Ve .Sp See \*(L"Standard placeholder types\*(R" for a list of types that Getopt::Euclid \&\fIdoes\fR recognize. .ie n .IP "Invalid .type constraint: %s" 4 .el .IP "Invalid .type constraint: \f(CW%s\fR" 4 .IX Item "Invalid .type constraint: %s" You specified a type constraint that is not valid Perl. For example: .Sp .Vb 2 \& =for Euclid \& max.type: integer not equals 0 .Ve .Sp instead of: .Sp .Vb 2 \& =for Euclid \& max.type: integer != 0 .Ve .ie n .IP "Invalid .default value: %s" 4 .el .IP "Invalid .default value: \f(CW%s\fR" 4 .IX Item "Invalid .default value: %s" You specified a default value that is not valid Perl. For example: .Sp .Vb 2 \& =for Euclid \& curse.default: *$@!& .Ve .Sp instead of: .Sp .Vb 2 \& =for Euclid \& curse.default: \*(Aq*$@!&\*(Aq .Ve .ie n .IP "Invalid .opt_default value: %s" 4 .el .IP "Invalid .opt_default value: \f(CW%s\fR" 4 .IX Item "Invalid .opt_default value: %s" Same as previous diagnostic, but for optional defaults. .ie n .IP "Invalid reference to field %s.default in argument description: %s" 4 .el .IP "Invalid reference to field \f(CW%s\fR.default in argument description: \f(CW%s\fR" 4 .IX Item "Invalid reference to field %s.default in argument description: %s" You referred to a default value in the description of an argument, but there is no such default. It may be a typo, or you may be referring to the default value for a different argument, e.g.: .Sp .Vb 1 \& =item \-a \& \& An optional age. Default: years.default \& \& =for Euclid \& age.default: 21 .Ve .Sp instead of: .Sp .Vb 1 \& =item \-a \& \& An optional age. Default: age.default \& \& =for Euclid \& age.default: 21 .Ve .ie n .IP "Invalid reference to field %s.opt_default in argument description: %s" 4 .el .IP "Invalid reference to field \f(CW%s\fR.opt_default in argument description: \f(CW%s\fR" 4 .IX Item "Invalid reference to field %s.opt_default in argument description: %s" Same as previous diagnostic, but for optional defaults. .IP "Invalid .opt_default constraint: Placeholder <%s> must be optional" 4 .IX Item "Invalid .opt_default constraint: Placeholder <%s> must be optional" You specified an optional default but the placeholder that it affects is not an optional placeholder. For example: .Sp .Vb 1 \& =item \-l[[en][gth]] \& \& =for Euclid: \& l.opt_default: 123 .Ve .Sp instead of: .Sp .Vb 1 \& =item \-l[[en][gth]] [] \& \& =for Euclid: \& l.opt_default: 123 .Ve .ie n .IP "Invalid .opt_default constraint: Parameter %s must have a flag" 4 .el .IP "Invalid .opt_default constraint: Parameter \f(CW%s\fR must have a flag" 4 .IX Item "Invalid .opt_default constraint: Parameter %s must have a flag" You specified an optional default but the parameter that it affects is unflagged. For example: .Sp .Vb 1 \& =item \& \& =for Euclid: \& l.opt_default: 123 .Ve .Sp instead of: .Sp .Vb 1 \& =item \-l [] \& \& =for Euclid: \& l.opt_default: 123 .Ve .ie n .IP "Invalid .excludes value for variable %s: <%s> does not exist" 4 .el .IP "Invalid .excludes value for variable \f(CW%s:\fR <%s> does not exist" 4 .IX Item "Invalid .excludes value for variable %s: <%s> does not exist" You specified to exclude a variable that was not seen in the \s-1POD.\s0 Make sure that this is not a typo. .ie n .IP "Invalid constraint: %s (No <%s> placeholder in argument: %s)" 4 .el .IP "Invalid constraint: \f(CW%s\fR (No <%s> placeholder in argument: \f(CW%s\fR)" 4 .IX Item "Invalid constraint: %s (No <%s> placeholder in argument: %s)" You attempted to define a \f(CW\*(C`.type\*(C'\fR constraint for a placeholder that did not exist. Typically this is the result of the misspelling of a placeholder name: .Sp .Vb 1 \& =item \-foo \& \& =for Euclid: \& baz.type: integer .Ve .Sp or a \f(CW\*(C`=for Euclid:\*(C'\fR that has drifted away from its argument: .Sp .Vb 1 \& =item \-foo \& \& =item \-verbose \& \& =for Euclid: \& bar.type: integer .Ve .IP "Getopt::Euclid loaded a second time" 4 .IX Item "Getopt::Euclid loaded a second time" You tried to load the module twice in the same program. Getopt::Euclid does not work that way. Load it only once. .IP "Unknown mode ('%s')" 4 .IX Item "Unknown mode ('%s')" The only argument that a \f(CW\*(C`use Getopt::Euclid\*(C'\fR command accepts is \&\f(CW\*(Aq:minimal_keys\*(Aq\fR (see \*(L"Minimalist keys\*(R"). You specified something else instead (or possibly forgot to put a semicolon after \f(CW\*(C`use Getopt::Euclid\*(C'\fR). .IP "Internal error: minimalist mode caused arguments '%s' and '%s' to clash" 4 .IX Item "Internal error: minimalist mode caused arguments '%s' and '%s' to clash" Minimalist mode removes certain characters from the keys hat are returned in \f(CW%ARGV\fR. This can mean that two command-line options (such as \f(CW\*(C`\-\-step\*(C'\fR and \f(CW\*(C`\*(C'\fR) map to the same key (i.e. \f(CW\*(Aqstep\*(Aq\fR). This in turn means that one of the two options has overwritten the other within the \f(CW%ARGV\fR hash. The program developer should either turn off \&\f(CW\*(Aq:minimal_keys\*(Aq\fR mode within the program, or else change the name of one of the options so that the two no longer clash. .SS "Run-time diagnostics" .IX Subsection "Run-time diagnostics" The following diagnostics are caused by problems in parsing the command-line .ie n .IP "Missing required argument(s): %s" 4 .el .IP "Missing required argument(s): \f(CW%s\fR" 4 .IX Item "Missing required argument(s): %s" At least one argument specified in the \f(CW\*(C`REQUIRED ARGUMENTS\*(C'\fR \s-1POD\s0 section was not present on the command-line. .ie n .IP "Invalid %s argument. %s must be %s but the supplied value (%s) is not." 4 .el .IP "Invalid \f(CW%s\fR argument. \f(CW%s\fR must be \f(CW%s\fR but the supplied value (%s) is not." 4 .IX Item "Invalid %s argument. %s must be %s but the supplied value (%s) is not." Getopt::Euclid recognized the argument you were trying to specify on the command-line, but the value you gave to one of that argument's placeholders was of the wrong type. .ie n .IP "Unknown argument: %s" 4 .el .IP "Unknown argument: \f(CW%s\fR" 4 .IX Item "Unknown argument: %s" Getopt::Euclid did not recognize an argument you were trying to specify on the command-line. This is often caused by command-line typos or an incomplete interface specification. .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" Getopt::Euclid requires no configuration files or environment variables. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" .IP "\(bu" 4 version .IP "\(bu" 4 Pod::Select .IP "\(bu" 4 Pod::PlainText .IP "\(bu" 4 File::Basename .IP "\(bu" 4 File::Spec::Functions .IP "\(bu" 4 List::Util .IP "\(bu" 4 Text::Balanced .IP "\(bu" 4 IO::Pager::Page (recommended) .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" Getopt::Euclid may not work properly with \s-1POD\s0 in Perl files that have been converted into an executable with PerlApp or similar software. A possible workaround may be to move the \s-1POD\s0 to a _\|_DATA_\|_ section or a separate .pod file. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-getopt\-euclid@rt.cpan.org\*(C'\fR, or through the web interface at . .PP Getopt::Euclid has a development repository on Sourceforge.net at in which the code is managed by Git. Feel free to clone this repository and push patches! To get started: git clone ) git branch 0.2.x origin/0.2.x git checkout 0.2.x .SH "AUTHOR" .IX Header "AUTHOR" Damian Conway \f(CW\*(C`\*(C'\fR .PP Florent Angly \f(CW\*(C`\*(C'\fR .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" Copyright (c) 2005, Damian Conway \f(CW\*(C`\*(C'\fR. All rights reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER OF WARRANTY" .IX Header "DISCLAIMER OF WARRANTY" \&\s-1BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE \*(L"AS IS\*(R" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.\s0 .PP \&\s-1IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE \s0(\s-1INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE\s0), \s-1EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\s0