aboutsummaryrefslogtreecommitdiff
path: root/renrot
diff options
context:
space:
mode:
authorAndy Shevchenko <andy@smile.org.ua>2012-07-28 18:13:01 +0000
committerAndy Shevchenko <andy@smile.org.ua>2012-07-28 18:13:01 +0000
commitdb0f802fbe685cd1e40f09c3789f5ca241648f62 (patch)
tree1eb4cdec2a10deb178057f411e13f926acde3a30 /renrot
parentd2dd2085024b382ee60c3fbdff8effcddda1d408 (diff)
downloadrenrot-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-xrenrot47
1 files changed, 13 insertions, 34 deletions
diff --git a/renrot b/renrot
index 3fbbf31..f1dc4ec 100755
--- a/renrot
+++ b/renrot
@@ -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;
}

Return to:

Send suggestions and report system problems to the System administrator.