summaryrefslogtreecommitdiff
path: root/ext/Pod-Html/lib/Pod/Html/Util.pm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/Pod-Html/lib/Pod/Html/Util.pm')
-rw-r--r--ext/Pod-Html/lib/Pod/Html/Util.pm98
1 files changed, 40 insertions, 58 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html/Util.pm b/ext/Pod-Html/lib/Pod/Html/Util.pm
index 9f33bff91e..bf95703a78 100644
--- a/ext/Pod-Html/lib/Pod/Html/Util.pm
+++ b/ext/Pod-Html/lib/Pod/Html/Util.pm
@@ -9,7 +9,7 @@ our @EXPORT_OK = qw(
anchorify
html_escape
htmlify
- parse_command_line
+ process_command_line
relativize_url
trim_leading_whitespace
unixify
@@ -41,72 +41,54 @@ just described.
=cut
-# parse_command_line will be moved back to lib/Pod/Html.pm in a subsequent
-# p.r. and will be documented then and there
+=head2 C<process_command_line()>
-sub parse_command_line {
- my $globals = shift;
- my ($opt_backlink,$opt_cachedir,$opt_css,$opt_flush,$opt_header,
- $opt_help,$opt_htmldir,$opt_htmlroot,$opt_index,$opt_infile,
- $opt_outfile,$opt_poderrors,$opt_podpath,$opt_podroot,
- $opt_quiet,$opt_recurse,$opt_title,$opt_verbose);
+Process command-line switches (options). Returns a reference to a hash. Will
+provide usage message if C<--help> switch is present or if parameters are
+invalid.
+Calling this subroutine may modify C<@ARGV>.
+
+=cut
+
+sub process_command_line {
+ my %opts = map { $_ => undef } (qw|
+ backlink cachedir css flush
+ header help htmldir htmlroot
+ index infile outfile poderrors
+ podpath podroot quiet recurse
+ title verbose
+ |);
unshift @ARGV, split ' ', $Config{pod2html} if $Config{pod2html};
- my $result = GetOptions(
- 'backlink!' => \$opt_backlink,
- 'cachedir=s' => \$opt_cachedir,
- 'css=s' => \$opt_css,
- 'flush' => \$opt_flush,
- 'help' => \$opt_help,
- 'header!' => \$opt_header,
- 'htmldir=s' => \$opt_htmldir,
- 'htmlroot=s' => \$opt_htmlroot,
- 'index!' => \$opt_index,
- 'infile=s' => \$opt_infile,
- 'outfile=s' => \$opt_outfile,
- 'poderrors!' => \$opt_poderrors,
- 'podpath=s' => \$opt_podpath,
- 'podroot=s' => \$opt_podroot,
- 'quiet!' => \$opt_quiet,
- 'recurse!' => \$opt_recurse,
- 'title=s' => \$opt_title,
- 'verbose!' => \$opt_verbose,
+ my $result = GetOptions(\%opts,
+ 'backlink!',
+ 'cachedir=s',
+ 'css=s',
+ 'flush',
+ 'help',
+ 'header!',
+ 'htmldir=s',
+ 'htmlroot=s',
+ 'index!',
+ 'infile=s',
+ 'outfile=s',
+ 'poderrors!',
+ 'podpath=s',
+ 'podroot=s',
+ 'quiet!',
+ 'recurse!',
+ 'title=s',
+ 'verbose!',
);
usage("-", "invalid parameters") if not $result;
-
- usage("-") if defined $opt_help; # see if the user asked for help
- $opt_help = ""; # just to make -w shut-up.
-
- @{$globals->{Podpath}} = split(":", $opt_podpath) if defined $opt_podpath;
-
- $globals->{Backlink} = $opt_backlink if defined $opt_backlink;
- $globals->{Cachedir} = unixify($opt_cachedir) if defined $opt_cachedir;
- $globals->{Css} = $opt_css if defined $opt_css;
- $globals->{Header} = $opt_header if defined $opt_header;
- $globals->{Htmldir} = unixify($opt_htmldir) if defined $opt_htmldir;
- $globals->{Htmlroot} = unixify($opt_htmlroot) if defined $opt_htmlroot;
- $globals->{Doindex} = $opt_index if defined $opt_index;
- $globals->{Podfile} = unixify($opt_infile) if defined $opt_infile;
- $globals->{Htmlfile} = unixify($opt_outfile) if defined $opt_outfile;
- $globals->{Poderrors} = $opt_poderrors if defined $opt_poderrors;
- $globals->{Podroot} = unixify($opt_podroot) if defined $opt_podroot;
- $globals->{Quiet} = $opt_quiet if defined $opt_quiet;
- $globals->{Recurse} = $opt_recurse if defined $opt_recurse;
- $globals->{Title} = $opt_title if defined $opt_title;
- $globals->{Verbose} = $opt_verbose if defined $opt_verbose;
-
- warn "Flushing directory caches\n"
- if $opt_verbose && defined $opt_flush;
- $globals->{Dircache} = "$globals->{Cachedir}/pod2htmd.tmp";
- if (defined $opt_flush) {
- 1 while unlink($globals->{Dircache});
- }
- return $globals;
+ usage("-") if defined $opts{help}; # see if the user asked for help
+ $opts{help} = ""; # just to make -w shut-up.
+ return \%opts;
}
=head2 C<usage()>
-Display customary Pod::Html usage information.
+Display customary Pod::Html usage information on STDERR.
=cut