diff options
author | Andy Shevchenko <andy@smile.org.ua> | 2012-07-28 18:13:01 +0000 |
---|---|---|
committer | Andy Shevchenko <andy@smile.org.ua> | 2012-07-28 18:13:01 +0000 |
commit | db0f802fbe685cd1e40f09c3789f5ca241648f62 (patch) | |
tree | 1eb4cdec2a10deb178057f411e13f926acde3a30 /renrot | |
parent | d2dd2085024b382ee60c3fbdff8effcddda1d408 (diff) | |
download | renrot-db0f802fbe685cd1e40f09c3789f5ca241648f62.tar.gz renrot-db0f802fbe685cd1e40f09c3789f5ca241648f62.tar.bz2 |
doc: update usage() to cover few more cases
Now usage() will print either version or short list of options, or full
documentation via pod2usage.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
git-svn-id: file:///svnroot/renrot/trunk@614 fe2816f4-e837-0410-b10a-f608c9d244a1
Diffstat (limited to 'renrot')
-rwxr-xr-x | renrot | 47 |
1 files changed, 13 insertions, 34 deletions
@@ -302,6 +302,4 @@ sub die_renrot { # See Also : Getopt::Long GetOptions() sub getOptions { - my $showVersion = 0; # need version - my $showHelp = 0; # need help my @tmpTags = (); @@ -327,5 +325,5 @@ sub getOptions { }; - my $getOptions = GetOptions ( + GetOptions ( # AGGREGATION "aggr-opts=s" => \$s_aggr_opts, @@ -385,5 +383,5 @@ sub getOptions { "extension|e=s" => \$extToProcess, "generate-thumb|g" => \$gen_thm, - "help|?" => \$showHelp, + "help|?" => sub { usage(0, 2) }, "no-rename|norename" => \$noRename, "no-rotate|norotate" => \$noRotation, @@ -398,7 +396,7 @@ sub getOptions { "user-comment=s" => \$userComment, "v+" => \$verbose, - "version" => \$showVersion, + "version" => sub { usage(0, 0) }, "work-directory|d=s" => \$workDir, - ); + ) or usage(1, 1); # Set the verbosity first @@ -448,14 +446,4 @@ sub getOptions { ldbg3("ARGV:\n", join("\n", @ARGV)) if ($fileCount > 0); - if ($showHelp != 0) { - usage(); - exit 0; - } - - if ($showVersion != 0) { - infomsg ("RenRot version $VERSION (r$REVISION)\n"); - exit 0; - } - if ($extToProcess eq "" and ($fileCount == 0) and $subFileSet eq "") { fatalmsg ("Extension of files is required!\n"); @@ -467,9 +455,4 @@ sub getOptions { } - if ($getOptions == 0) { - usage(); - exit 1; - } - if ($noRenRoTagMtm != 0) { $noRename = $noRotation = $noTags = 1; @@ -1576,13 +1559,10 @@ sub rotateThumbnail { # sub usage { - # catch warnings if we have problems running perldoc - my $evalWarning; - local $SIG{'__WARN__'} = sub { $evalWarning = $_[0] }; - my $dummy = \*SAVEERR; # avoid "used only once" warning - unless ($^O eq 'os2') { - open SAVEERR, ">&STDERR"; - open STDERR, '>/dev/null'; - } - if (system('perldoc', $0)) { + my $exitcode = shift; + my $verbose = shift; + + if ($verbose == 0) { + infomsg ("RenRot version $VERSION (r$REVISION)\n"); + } elsif ($verbose == 1) { infomsg ( "Usage: renrot <--extension EXTENSION> [--quiet] [--no-rotate] [--no-rename] @@ -1619,9 +1599,8 @@ Consult the documentation for a full list of options. "); + } elsif ($verbose == 2) { + pod2usage(-verbose => 2); } - unless ($^O eq 'os2') { - close STDERR; - open STDERR, '>&SAVEERR'; - } + exit $exitcode; } |