aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andy@smile.org.ua>2006-09-05 05:07:47 +0000
committerAndy Shevchenko <andy@smile.org.ua>2006-09-05 05:07:47 +0000
commiteecea3faee68010f90a79e75a85d79b5fb5a37a3 (patch)
tree5e34297915e2a57a2a5f757ee487e12eb4108620
parent22de7865dea4af5d8e82ccc1ad8f8f32c15c2d53 (diff)
downloadrenrot-eecea3faee68010f90a79e75a85d79b5fb5a37a3.tar.gz
renrot-eecea3faee68010f90a79e75a85d79b5fb5a37a3.tar.bz2
Remove --color. Add 'use color' to configuration file.
git-svn-id: file:///svnroot/renrot/trunk@258 fe2816f4-e837-0410-b10a-f608c9d244a1
-rw-r--r--ChangeLog4
-rw-r--r--TODO7
-rw-r--r--etc/colors.conf3
-rwxr-xr-xrenrot47
4 files changed, 23 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index bea888f..70e723b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1$Log$ 1$Log$
2Revision 1.163 2006/09/05 05:07:47 andy
3Remove --color. Add 'use color' to configuration file.
4
2Revision 1.162 2006/09/02 18:29:20 andy 5Revision 1.162 2006/09/02 18:29:20 andy
3Optimize hash parser. 6Optimize hash parser.
4 7
@@ -638,3 +641,4 @@ Id keyword is added to renrot file.
638 641
639Revision 1.1 2005/10/17 13:39:38 zeus 642Revision 1.1 2005/10/17 13:39:38 zeus
640ChangeLog file is added. Its the very begining. 643ChangeLog file is added. Its the very begining.
644
diff --git a/TODO b/TODO
index b4db37d..c96e996 100644
--- a/TODO
+++ b/TODO
@@ -7,6 +7,13 @@ TODO SEMANTICS
7q optional feature 7q optional feature
8 8
9 9
10BUGS
11
12- fix cleaning EXIFs when --no-backup is given
13
14- make possible to use same EXIF tags in different groups
15
16
10EXIF tags 17EXIF tags
11 18
12q to write to some tag the options passed to renrot 19q to write to some tag the options passed to renrot
diff --git a/etc/colors.conf b/etc/colors.conf
index 73297ce..2ac6e60 100644
--- a/etc/colors.conf
+++ b/etc/colors.conf
@@ -3,6 +3,9 @@
3# 3#
4# Note: These variables can be overriden by command line options. 4# Note: These variables can be overriden by command line options.
5 5
6# Use colorized output. This NOT works under Win32.
7#Use color = No
8
6# Setup colors for different facilities 9# Setup colors for different facilities
7 10
8#Color = debug: 'green' 11#Color = debug: 'green'
diff --git a/renrot b/renrot
index 83416a4..8844fdf 100755
--- a/renrot
+++ b/renrot
@@ -70,6 +70,7 @@ my %configOptions = (
70 'mtime' => 1, 70 'mtime' => 1,
71 'name template' => '%Y%m%d%H%M%S', 71 'name template' => '%Y%m%d%H%M%S',
72 'trim' => 1, 72 'trim' => 1,
73 'use color' => 0,
73 'use ipc' => 0, 74 'use ipc' => 0,
74 ); 75 );
75 76
@@ -84,7 +85,6 @@ my $aggrTemplate; # template for the files aggregation taken from CLI
84my $aggrVirtual; # flag to do links instead real file moving while aggregation 85my $aggrVirtual; # flag to do links instead real file moving while aggregation
85my $aggrVirtDir; # directory name for virtual aggregation 86my $aggrVirtDir; # directory name for virtual aggregation
86my $backup = 1; # make or not a backup of the original files 87my $backup = 1; # make or not a backup of the original files
87my %colorsFromCli; # colors are got from CLI
88my $comfile; # file with commentary 88my $comfile; # file with commentary
89my $configFile; # configuration file 89my $configFile; # configuration file
90my $countFF = 1; # use fixed field for counter 90my $countFF = 1; # use fixed field for counter
@@ -203,7 +203,7 @@ my %colors = (
203sub printColored { 203sub printColored {
204 my $facility = shift; 204 my $facility = shift;
205 205
206 if (defined $useColor and $useColor != 0) { 206 if ($configOptions{'use color'} != 0) {
207 if (defined $facility and defined $colors{$facility}) { 207 if (defined $facility and defined $colors{$facility}) {
208 print STDERR colored [$colors{$facility}{value}], @_; 208 print STDERR colored [$colors{$facility}{value}], @_;
209 return; 209 return;
@@ -217,7 +217,7 @@ sub printColored {
217sub procmsg { 217sub procmsg {
218 return if ($quiet != 0); 218 return if ($quiet != 0);
219 219
220 if (defined $useColor and $useColor != 0) { 220 if ($configOptions{'use color'} != 0) {
221 if (defined $colors{'process'}) { 221 if (defined $colors{'process'}) {
222 print colored [$colors{'process'}{value}], @_; 222 print colored [$colors{'process'}{value}], @_;
223 return; 223 return;
@@ -289,7 +289,6 @@ sub boolConverter {
289sub getOptions { 289sub getOptions {
290 my $showVersion = 0; # need version 290 my $showVersion = 0; # need version
291 my $showHelp = 0; # need help 291 my $showHelp = 0; # need help
292 my @tmpColors;
293 my @tmpTags; 292 my @tmpTags;
294 my $getOptions = GetOptions ( 293 my $getOptions = GetOptions (
295 "aggr-delta=i" => \$aggrDelta, 294 "aggr-delta=i" => \$aggrDelta,
@@ -299,7 +298,6 @@ sub getOptions {
299 "aggr-virtual!" => \$aggrVirtual, 298 "aggr-virtual!" => \$aggrVirtual,
300 "aggr-virtual-directory=s" => \$aggrVirtDir, 299 "aggr-virtual-directory=s" => \$aggrVirtDir,
301 "backup!" => \$backup, 300 "backup!" => \$backup,
302 "color=s" => \@tmpColors,
303 "comment-file=s" => \$comfile, 301 "comment-file=s" => \$comfile,
304 "config-file|c=s" => \$configFile, 302 "config-file|c=s" => \$configFile,
305 "counter-fixed-field!" => \$countFF, 303 "counter-fixed-field!" => \$countFF,
@@ -340,7 +338,6 @@ sub getOptions {
340 dbgmsg (3, " --aggr-virtual: ", boolConv($aggrVirtual), "\n") if (defined $aggrVirtual); 338 dbgmsg (3, " --aggr-virtual: ", boolConv($aggrVirtual), "\n") if (defined $aggrVirtual);
341 dbgmsg (3, " --aggr-virtual-directory: $aggrVirtDir\n") if (defined $aggrVirtDir); 339 dbgmsg (3, " --aggr-virtual-directory: $aggrVirtDir\n") if (defined $aggrVirtDir);
342 dbgmsg (3, " --backup: ", boolConv($backup), "\n"); 340 dbgmsg (3, " --backup: ", boolConv($backup), "\n");
343 dbgmsg (3, " --color:\n", join("\n", @tmpColors), "\n") if (scalar(@tmpColors) > 0);
344 dbgmsg (3, " --comment-file: $comfile\n") if (defined $comfile); 341 dbgmsg (3, " --comment-file: $comfile\n") if (defined $comfile);
345 dbgmsg (3, " --config-file: $configFile\n") if (defined $configFile); 342 dbgmsg (3, " --config-file: $configFile\n") if (defined $configFile);
346 dbgmsg (3, " --counter-start: $countStart", 343 dbgmsg (3, " --counter-start: $countStart",
@@ -395,20 +392,10 @@ sub getOptions {
395 $extToProcess =~ s/^\*?\.?/\./ if ($fileCount == 0); 392 $extToProcess =~ s/^\*?\.?/\./ if ($fileCount == 0);
396 dbgmsg (1, "getOptions(): Process with '$extToProcess' extension.\n"); 393 dbgmsg (1, "getOptions(): Process with '$extToProcess' extension.\n");
397 394
398 # Convert multiple color parameters to colors hash
399 foreach my $colorStr (@tmpColors) {
400 my %color = strToHash($colorStr, 'reset');
401 foreach my $key (keys %color) {
402 $colorsFromCli{$key} = $color{$key};
403 }
404 }
405
406 # Convert multiple tag parameters to tags hash 395 # Convert multiple tag parameters to tags hash
407 foreach my $tagStr (@tmpTags) { 396 foreach my $tagStr (@tmpTags) {
408 my %tag = strToHash($tagStr); 397 my %tag = strToHash($tagStr);
409 foreach my $key (keys %tag) { 398 map { $tagsFromCli{$_} = $tag{$_} } keys %tag;
410 $tagsFromCli{$key} = $tag{$key};
411 }
412 } 399 }
413} 400}
414 401
@@ -519,9 +506,7 @@ sub parseConfigFile {
519 my %hConfig = @_; 506 my %hConfig = @_;
520 if (-f $file) { 507 if (-f $file) {
521 my %tmpConfig = getConfig($fc + 1, $file); 508 my %tmpConfig = getConfig($fc + 1, $file);
522 foreach my $key (keys %tmpConfig) { 509 map { $hConfig{$_} = $tmpConfig{$_} } keys %tmpConfig;
523 $hConfig{$key} = $tmpConfig{$key};
524 }
525 } 510 }
526 return %hConfig; 511 return %hConfig;
527} 512}
@@ -593,19 +578,14 @@ sub dirValidator {
593# switchColor() switches to user defined color scheme 578# switchColor() switches to user defined color scheme
594# 579#
595sub switchColor { 580sub switchColor {
596 dbgmsg (1, "Switch to user defined color scheme.\n");
597
598 # Parse configuration file color set 581 # Parse configuration file color set
599 foreach my $cKey (keys %configOptions) { 582 foreach my $cKey (keys %configOptions) {
600 next if ($cKey !~ m/^color#\d+#\d+$/); # skip not a color 583 next if ($cKey !~ m/^color#\d+#\d+$/); # skip not a color
601 my %color = strToHash($configOptions{$cKey}, 'reset'); 584 my %color = strToHash($configOptions{$cKey}, 'reset');
602 foreach my $key (keys %color) { 585 map { $colors{$_} = $color{$_} } keys %color;
603 $colors{$key} = $color{$key};
604 }
605 } 586 }
606 587
607 # Merge colors from configuration file with command line arguments 588 dbgmsg (1, "Switch to user defined color scheme.\n");
608 map { $colors{$_} = $colorsFromCli{$_} } keys %colorsFromCli;
609} 589}
610 590
611######################################################################################## 591########################################################################################
@@ -613,11 +593,8 @@ sub switchColor {
613# MAIN() renames and rotates given files 593# MAIN() renames and rotates given files
614# 594#
615 595
616# parse command line options
617getOptions(); 596getOptions();
618
619parseConfig($configFile); 597parseConfig($configFile);
620
621switchColor(); 598switchColor();
622 599
623# redefining options set in configuration file with set via CLI ones 600# redefining options set in configuration file with set via CLI ones
@@ -633,6 +610,7 @@ $configOptions{'keywords replace'} = $keywordsReplace if (defined $keywordsRepla
633$configOptions{'mtime'} = $mtime if (defined $mtime); 610$configOptions{'mtime'} = $mtime if (defined $mtime);
634$configOptions{'name template'} = $nameTemplate if (defined $nameTemplate); 611$configOptions{'name template'} = $nameTemplate if (defined $nameTemplate);
635$configOptions{'trim'} = $trim if (defined $trim); 612$configOptions{'trim'} = $trim if (defined $trim);
613$configOptions{'use color'} = $useColor if (defined $useColor);
636$configOptions{'use ipc'} = $useIPC if (defined $useIPC); 614$configOptions{'use ipc'} = $useIPC if (defined $useIPC);
637 615
638dbgmsg (1, "main(): Show what would have been happened (no real actions).\n") if ($dryRun != 0); 616dbgmsg (1, "main(): Show what would have been happened (no real actions).\n") if ($dryRun != 0);
@@ -710,9 +688,7 @@ $tags{'Comment'} = {value => getFileData($comfile)} if (defined $comfile);
710$tags{'UserComment'} = {value => $userComment} if (defined $userComment); 688$tags{'UserComment'} = {value => $userComment} if (defined $userComment);
711 689
712# Merge tags from configuration file with command line arguments 690# Merge tags from configuration file with command line arguments
713foreach my $key (keys %tagsFromCli) { 691map { $tags{$_} = $tagsFromCli{$_} } keys %tagsFromCli;
714 $tags{$key} = $tagsFromCli{$key};
715}
716 692
717# Print parsed tags at debug level 693# Print parsed tags at debug level
718my @dbgTags; 694my @dbgTags;
@@ -1406,7 +1382,6 @@ Tag writing options:
1406 1382
1407Colorizing options: 1383Colorizing options: