aboutsummaryrefslogtreecommitdiff
path: root/renrot
diff options
context:
space:
mode:
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
@@ -301,8 +301,6 @@ sub die_renrot {
301# Comments : none 301# Comments : none
302# See Also : Getopt::Long GetOptions() 302# See Also : Getopt::Long GetOptions()
303sub getOptions { 303sub getOptions {
304 my $showVersion = 0; # need version
305 my $showHelp = 0; # need help
306 my @tmpTags = (); 304 my @tmpTags = ();
307 305
308 # For 'aggregation' 306 # For 'aggregation'
@@ -326,7 +324,7 @@ sub getOptions {
326 'keywords' => { 's' => \$s_kw_opts, 'h' => \%h_kw_opts }, 324 'keywords' => { 's' => \$s_kw_opts, 'h' => \%h_kw_opts },
327 }; 325 };
328 326
329 my $getOptions = GetOptions ( 327 GetOptions (
330 # AGGREGATION 328 # AGGREGATION
331 "aggr-opts=s" => \$s_aggr_opts, 329 "aggr-opts=s" => \$s_aggr_opts,
332 "aggr-delta=i" => \$h_aggr_opts{'delta'}, 330 "aggr-delta=i" => \$h_aggr_opts{'delta'},
@@ -384,7 +382,7 @@ sub getOptions {
384 "exclude=s" => \@excludeList, 382 "exclude=s" => \@excludeList,
385 "extension|e=s" => \$extToProcess, 383 "extension|e=s" => \$extToProcess,
386 "generate-thumb|g" => \$gen_thm, 384 "generate-thumb|g" => \$gen_thm,
387 "help|?" => \$showHelp, 385 "help|?" => sub { usage(0, 2) },
388 "no-rename|norename" => \$noRename, 386 "no-rename|norename" => \$noRename,
389 "no-rotate|norotate" => \$noRotation, 387 "no-rotate|norotate" => \$noRotation,
390 "no-tags|notags" => \$noTags, 388 "no-tags|notags" => \$noTags,
@@ -397,9 +395,9 @@ sub getOptions {
397 "tag|t=s" => \@tmpTags, 395 "tag|t=s" => \@tmpTags,
398 "user-comment=s" => \$userComment, 396 "user-comment=s" => \$userComment,
399 "v+" => \$verbose, 397 "v+" => \$verbose,
400 "version" => \$showVersion, 398 "version" => sub { usage(0, 0) },
401 "work-directory|d=s" => \$workDir, 399 "work-directory|d=s" => \$workDir,
402 ); 400 ) or usage(1, 1);
403 401
404 # Set the verbosity first 402 # Set the verbosity first
405 Image::RenRot::Logging->set(Quiet => $quiet, 403 Image::RenRot::Logging->set(Quiet => $quiet,
@@ -447,16 +445,6 @@ sub getOptions {
447 ldbg3("--work-directory: $workDir"); 445 ldbg3("--work-directory: $workDir");
448 ldbg3("ARGV:\n", join("\n", @ARGV)) if ($fileCount > 0); 446 ldbg3("ARGV:\n", join("\n", @ARGV)) if ($fileCount > 0);
449 447
450 if ($showHelp != 0) {
451 usage();
452 exit 0;
453 }
454
455 if ($showVersion != 0) {
456 infomsg ("RenRot version $VERSION (r$REVISION)\n");
457 exit 0;
458 }
459
460 if ($extToProcess eq "" and ($fileCount == 0) and $subFileSet eq "") { 448 if ($extToProcess eq "" and ($fileCount == 0) and $subFileSet eq "") {
461 fatalmsg ("Extension of files is required!\n"); 449 fatalmsg ("Extension of files is required!\n");
462 exit 1; 450 exit 1;
@@ -466,11 +454,6 @@ sub getOptions {
466 warnmsg ("Extension of files will be ignored!\n"); 454 warnmsg ("Extension of files will be ignored!\n");
467 } 455 }
468 456
469 if ($getOptions == 0) {
470 usage();
471 exit 1;
472 }
473
474 if ($noRenRoTagMtm != 0) { 457 if ($noRenRoTagMtm != 0) {
475 $noRename = $noRotation = $noTags = 1; 458 $noRename = $noRotation = $noTags = 1;
476 update_cfg_value($config_opts->{'general'}{'mtime'}, 0); 459 update_cfg_value($config_opts->{'general'}{'mtime'}, 0);
@@ -1575,15 +1558,12 @@ sub rotateThumbnail {
1575# usage() prints the instructions how to use the script 1558# usage() prints the instructions how to use the script
1576# 1559#
1577sub usage { 1560sub usage {
1578 # catch warnings if we have problems running perldoc 1561 my $exitcode = shift;
1579 my $evalWarning; 1562 my $verbose = shift;
1580 local $SIG{'__WARN__'} = sub { $evalWarning = $_[0] }; 1563
1581 my $dummy = \*SAVEERR; # avoid "used only once" warning 1564 if ($verbose == 0) {
1582 unless ($^O eq 'os2') { 1565 infomsg ("RenRot version $VERSION (r$REVISION)\n");
1583 open SAVEERR, ">&STDERR"; 1566 } elsif ($verbose == 1) {
1584 open STDERR, '>/dev/null';
1585 }
1586 if (system('perldoc', $0)) {
1587 infomsg ( 1567 infomsg (
1588"Usage: renrot <--extension EXTENSION> [--quiet] [--no-rotate] [--no-rename] 1568"Usage: renrot <--extension EXTENSION> [--quiet] [--no-rotate] [--no-rename]
1589 [--name-template TPL] [--comment-file FILE] [--work-directory DIR] 1569 [--name-template TPL] [--comment-file FILE] [--work-directory DIR]
@@ -1618,11 +1598,10 @@ or '--no-mtime' disables setting it.
1618Consult the documentation for a full list of options. 1598Consult the documentation for a full list of options.
1619 1599
1620"); 1600");
1601 } elsif ($verbose == 2) {
1602 pod2usage(-verbose => 2);
1621 } 1603 }
1622 unless ($^O eq 'os2') { 1604 exit $exitcode;
1623 close STDERR;
1624 open STDERR, '>&SAVEERR';
1625 }
1626} 1605}
1627 1606
1628######################################################################################## 1607########################################################################################

Return to:

Send suggestions and report system problems to the System administrator.