summaryrefslogtreecommitdiffabout
authorAndy Shevchenko <andy@smile.org.ua>2012-07-28 18:13:01 (GMT)
committer Andy Shevchenko <andy@smile.org.ua>2012-07-28 18:13:01 (GMT)
commitdb0f802fbe685cd1e40f09c3789f5ca241648f62 (patch) (side-by-side diff)
tree1eb4cdec2a10deb178057f411e13f926acde3a30
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 (more/less context) (show whitespace changes)
-rwxr-xr-xrenrot47
1 files changed, 13 insertions, 34 deletions
diff --git a/renrot b/renrot
index 3fbbf31..f1dc4ec 100755
--- a/renrot
+++ b/renrot
@@ -303,4 +303,2 @@ sub die_renrot {
sub getOptions {
- my $showVersion = 0; # need version
- my $showHelp = 0; # need help
my @tmpTags = ();
@@ -328,3 +326,3 @@ sub getOptions {
- my $getOptions = GetOptions (
+ GetOptions (
# AGGREGATION
@@ -386,3 +384,3 @@ sub getOptions {
"generate-thumb|g" => \$gen_thm,
- "help|?" => \$showHelp,
+ "help|?" => sub { usage(0, 2) },
"no-rename|norename" => \$noRename,
@@ -399,5 +397,5 @@ sub getOptions {
"v+" => \$verbose,
- "version" => \$showVersion,
+ "version" => sub { usage(0, 0) },
"work-directory|d=s" => \$workDir,
- );
+ ) or usage(1, 1);
@@ -449,12 +447,2 @@ sub getOptions {
- 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 "") {
@@ -468,7 +456,2 @@ sub getOptions {
- if ($getOptions == 0) {
- usage();
- exit 1;
- }
-
if ($noRenRoTagMtm != 0) {
@@ -1577,11 +1560,8 @@ 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 (
@@ -1620,7 +1600,6 @@ 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.