NAME
[@$og{package}@] - [@$og{purpose}@]
VERSION
Version [@$og{version}@]
SYNOPSIS
[@
$OUT .= $og{package};
$OUT .= ' [OPTIONS]' if (@{$og{optl}});
if ($og{unnamed}) {
if (@{$og{args}}) {
$OUT .= join("", map { " $_->{name}" } @{$og{args}});
}
else {
$OUT .= " FILE(s)...";
}
}
@]
[@
#// -- summary: argument descriptions
if ($og{unnamed} && @{$og{args}}) {
my ($arg,$maxarglen);
#// -- get argument field-lengths
foreach $arg (@{$og{args}}) {
$maxarglen = length($arg->{name})
if (!defined($maxarglen) || $maxarglen < length($arg));
}
$OUT .=
join("\n ",
"",
q{Arguments:},
map {
sprintf(" %-${maxarglen}s %s", $_->{name}, $_->{descr})
} @{$og{args}});
}
#// -- summary: option descriptions
if (@{$og{optl}}) {
#// -- get option field-lengths
my ($optid,$opt,$maxshortlen,$maxlonglen,$oshortlen,$olonglen);
my ($short,$long,$descr);
foreach $opt (values(%{$og{opth}})) {
$oshortlen = defined($opt->{short}) ? 2 : 0;
$olonglen = defined($opt->{long}) ? length($opt->{long}) : 0;
if ($opt->{arg}) {
$oshortlen += length($opt->{arg});
$olonglen += 1+length($opt->{arg});
}
$maxshortlen = $oshortlen
if (!defined($maxshortlen) || $maxshortlen < $oshortlen);
$maxlonglen = $olonglen
if (!defined($maxlonglen) || $maxlonglen < $olonglen);
}
#// -- print option summary
my $group = '';
foreach $optid (@{$og{optl}}) {
$opt = $og{opth}{$optid};
if ($opt->{group} ne $group) {
#// -- print group header
$group = $opt->{group};
$OUT .= "\n\n $group";
}
#// -- print option
$short = $long = $descr = '';
if (defined($opt->{short}) && $opt->{short} ne '-') {
$short = "-$opt->{short}";
$short .= $opt->{arg} if (defined($opt->{arg}));
}
if (defined($opt->{long}) && $opt->{long} ne '-') {
$long = $opt->{long};
$long = '--'.OptGen::string_value($long);
$long .= '='.$opt->{arg} if (defined($opt->{arg}));
}
next if ($short eq '' && !$og{longhelp});
$OUT .= ("\n "
.sprintf("%-${maxshortlen}s", $short)
.($og{longhelp} ? sprintf(" %-${maxlonglen}s", $long) : '')
.' '.$opt->{descr});
}
}
@]
DESCRIPTION
[@ $og{purpose} ? $og{purpose} : '' @]
[@ $og{details} ? $og{details} : '' @]
Documentation autogenerated by [@$og{name}@] version [@$og{OptGenVersion}@] with the following command:
[@$CMDLINE@]
[@ if ($og{unnamed}) { $OUT .= "=head1 ARGUMENTS\n\n=over 4\n\n"; if (@{$og{args}}) { foreach my $arg (@{$og{args}}) { my ($name,$descr) = @$arg{qw(name descr)}; $OUT .= ("=item * ".OptGen::podify($name)."
\n\n".OptGen::podify($descr)."\n\n"); } } else { $OUT .= "=item * FILE(s)
\n\nInput files.\n\n"; } } $OUT .= "=back\n\n"; @]
[@ if (@{$og{optl}}) { $OUT .= "=head1 OPTIONS\n\n=over 4\n\n"; my $group = 'Options'; ## -- use the default my ($short,$long,$descr,$optid,$opt); foreach $optid (@{$og{optl}}) { $opt = $og{opth}{$optid}; if ($opt->{group} ne $group) { $group = $opt->{group}; #// -- print last-group footer $OUT .= "=back\n\n=cut\n\n"; #// -- print new-group header $OUT .= ('#'.('-' x 62)."\n" ."# Option-Group $group\n" .'#'.('-' x 62)."\n" ."=pod\n\n=head2 $group\n\n=over 4\n\n"); } #// -- print option $short = $long = $descr = ''; if (defined($opt->{short}) && $opt->{short} ne '-') { $short = "-$opt->{short}"; $short .= $opt->{arg} if (defined($opt->{arg})); } if (defined($opt->{long}) && $opt->{long} ne '-') { $long = $opt->{long}; $long = '--'.OptGen::string_value($long); $long .= '='.$opt->{arg} if (defined($opt->{arg})); } $OUT .= ("=item * " .join(" , ", ($long ? ("".OptGen::podify($long)."
") : qw()), ($short ? ("".OptGen::podify($short)."
") : qw())) ."\n\n" .(defined($opt->{descr}) ? (OptGen::podify($opt->{descr})."\n\n") : '') .(defined($opt->{details}) ? (OptGen::podify($opt->{details})."\n\n") : '') ."\n\n"); } } #// -- print last-group footer $OUT .= "=back\n\n"; @]
BUGS
[@ if ($bugfile) { eval "use IO::File;"; $bugfh = IO::File->new("<$bugfile") or die("could not open bugfile '$bugfile': $!"); $OUT .= join(" ",<$bugfh>); $bugfh->close() } else { $OUT .= "Unknown.\n"; } @]
[@ if ($footerfile) { eval "use IO::File;"; $footfh = IO::File->new("<$footerfile") or die("could not open footer file '$footerfile': $!"); $OUT .= join(" ",<$footfh>); $footfh->close() } else { $OUT .= '
ACKNOWLEDGEMENTS
perl by Larry Wall.
AUTHOR
A. U. Thor, <a.u.thor@a.galaxy.far.far.away>
SEE ALSO
perl.