aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andy@smile.org.ua>2006-08-22 07:18:22 +0000
committerAndy Shevchenko <andy@smile.org.ua>2006-08-22 07:18:22 +0000
commit165a725a6cf238b9bf25e858a1c2af566e7c9655 (patch)
tree5b8b813b7c8b273b83862eb472d8f9248e65d458
parentf494599aecd21266e9852085b3b73cea48e760bd (diff)
downloadrenrot-165a725a6cf238b9bf25e858a1c2af566e7c9655.tar.gz
renrot-165a725a6cf238b9bf25e858a1c2af566e7c9655.tar.bz2
The colorization for output has been implemented, the options --use-color and
--color were added. git-svn-id: file:///svnroot/renrot/branches/RENROT_STABLE@249 fe2816f4-e837-0410-b10a-f608c9d244a1
-rw-r--r--ChangeLog5
-rw-r--r--NEWS12
-rw-r--r--etc/colors.conf13
-rw-r--r--etc/renrot.conf3
-rwxr-xr-xrenrot129
-rw-r--r--renrot.spec5
6 files changed, 153 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e53605..97b215c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
1$Log$ 1$Log$
2Revision 1.148.2.4 2006/08/22 07:18:22 andy
3The colorization for output has been implemented, the options --use-color and
4--color were added.
5
2Revision 1.148.2.3 2006/08/19 10:59:19 andy 6Revision 1.148.2.3 2006/08/19 10:59:19 andy
3Release as 0.23. 7Release as 0.23.
4 8
@@ -605,3 +609,4 @@ Id keyword is added to renrot file.
605 609
606Revision 1.1 2005/10/17 13:39:38 zeus 610Revision 1.1 2005/10/17 13:39:38 zeus
607ChangeLog file is added. Its the very begining. 611ChangeLog file is added. Its the very begining.
612
diff --git a/NEWS b/NEWS
index b34b557..7b11f78 100644
--- a/NEWS
+++ b/NEWS
@@ -1,12 +1,12 @@
1* 0.23 * 1* 0.23 *
2 2
3The additional template sequences %C, %O, and %o had been added. They are 3The additional template sequences %C, %O, and %o had been added. They
4represented the original filename counter, base part and full copy of the 4represent the original filename counter, base part, and full copy of the
5original filename respectively. A new tag RenRotFileNameOriginal is writing 5original filename respectively. A new tag, RenRotFileNameOriginal, is written
6after first pass by renrot. On a Win32 platform the home path is taken from 6after the first pass by renrot. On the Win32 platform, the home path is taken
7the environment variable USERPROFILE instead of HOME. The IPC support for 7from the environment variable USERPROFILE instead of HOME. The IPC support for
8rotating thumbnails has been added. The output messages of the usage function 8rotating thumbnails has been added. The output messages of the usage function
9had been reformatted. 9have been reformatted.
10 10
11 11
12* 0.22 * 12* 0.22 *
diff --git a/etc/colors.conf b/etc/colors.conf
new file mode 100644
index 0000000..73297ce
--- /dev/null
+++ b/etc/colors.conf
@@ -0,0 +1,13 @@
1#
2## This is configuration file for RenRot. See commented variables for defaults.
3#
4# Note: These variables can be overriden by command line options.
5
6# Setup colors for different facilities
7
8#Color = debug: 'green'
9#Color = error: 'magenta'
10#Color = fatal: 'red'
11#Color = info: 'bold'
12#Color = process: 'white'
13#Color = warning: 'cyan'
diff --git a/etc/renrot.conf b/etc/renrot.conf
index 6c62ba4..3b564e7 100644
--- a/etc/renrot.conf
+++ b/etc/renrot.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# Include color scheme
7#include = '/etc/renrot/colors.conf'
8
6# Whether to keywordize the files (see option --keywordize description for details) 9# Whether to keywordize the files (see option --keywordize description for details)
7#keywordize = No 10#keywordize = No
8 11
diff --git a/renrot b/renrot
index f489fcb..7307d3d 100755
--- a/renrot
+++ b/renrot
@@ -12,6 +12,11 @@ use Time::Local;
12use Image::ExifTool; 12use Image::ExifTool;
13use Getopt::Long; 13use Getopt::Long;
14 14
15use Term::ANSIColor;
16
17$Term::ANSIColor::AUTORESET = 1;
18$Term::ANSIColor::EACHLINE = "\n";
19
15our $VERSION = "0.23"; # the version of this script 20our $VERSION = "0.23"; # the version of this script
16my $maxVerbosity = 4; # our max verbosity level (internal) 21my $maxVerbosity = 4; # our max verbosity level (internal)
17 22
@@ -79,6 +84,7 @@ my $aggrTemplate; # template for the files aggregation taken from CLI
79my $aggrVirtual; # flag to do links instead real file moving while aggregation 84my $aggrVirtual; # flag to do links instead real file moving while aggregation
80my $aggrVirtDir; # directory name for virtual aggregation 85my $aggrVirtDir; # directory name for virtual aggregation
81my $backup = 1; # make or not a backup of the original files 86my $backup = 1; # make or not a backup of the original files
87my %colorsFromCli; # colors are got from CLI
82my $comfile; # file with commentary 88my $comfile; # file with commentary
83my $configFile; # configuration file 89my $configFile; # configuration file
84my $countFF = 1; # use fixed field for counter 90my $countFF = 1; # use fixed field for counter
@@ -101,6 +107,7 @@ my $rotateAngle; # define the angle to rotate on 90, 180 or 270
101my $rotateThumbnail; # define the angle to rotate on 90, 180 or 270 107my $rotateThumbnail; # define the angle to rotate on 90, 180 or 270
102my %tagsFromCli; # tags are got from CLI 108my %tagsFromCli; # tags are got from CLI
103my $trim; # jpegtran -trim 109my $trim; # jpegtran -trim
110my $useColor; # colorized output
104my $useIPC; # rotate thumbnail via pipe 111my $useIPC; # rotate thumbnail via pipe
105my $userComment; # text to put into UserComment tag 112my $userComment; # text to put into UserComment tag
106my $verbose = 0; # verbosity of output 113my $verbose = 0; # verbosity of output
@@ -173,41 +180,78 @@ my %rotorientrev = reverse %rotorient;
173my %incFiles; # hash of included files while parsing configuration file 180my %incFiles; # hash of included files while parsing configuration file
174 181
175my @multOpts = ( 182my @multOpts = (
183 'color',
184 'include',
176 'tag', 185 'tag',
177 'tagfile', 186 'tagfile',
178 'include',
179 ); 187 );
180 188
189########################################################################################
190#
191# Colors hash
192#
193my %colors = (
194 debug => 'green',
195 error => 'magenta',
196 fatal => 'red',
197 info => 'bold',
198 process => 'white',
199 warning => 'cyan',
200);
201
202# Prints colored message to STDERR
203sub printColored {
204 my $facility = shift;
205
206 if (defined $useColor and $useColor != 0) {
207 if (defined $facility and defined $colors{$facility}) {
208 print STDERR colored [$colors{$facility}], @_;
209 return;
210 }
211 }
212
213 print STDERR @_; # fallback to normal print
214}
215
181# processing message 216# processing message
182sub procmsg { 217sub procmsg {
183 print @_ if ($quiet == 0); 218 return if ($quiet != 0);
219
220 if (defined $useColor and $useColor != 0) {
221 if (defined $colors{'process'}) {
222 print colored [$colors{'process'}], @_;
223 return;
224 }
225 }
226
227 print @_; # fallback to normal print
184} 228}
185 229
186# information message 230# information message
187sub infomsg { 231sub infomsg {
188 print STDERR @_; 232 printColored('info', @_);
189} 233}
190 234
191# warning message 235# warning message
192sub warnmsg { 236sub warnmsg {
193 print STDERR "Warning: ", @_; 237 printColored('warning', "Warning: ", @_);
194} 238}
195 239
196# error message 240# error message
197sub errmsg { 241sub errmsg {
198 print STDERR "ERROR: ", @_; 242 printColored('error', "ERROR: ", @_);
199} 243}
200 244
201# fatal message 245# fatal message
202sub fatalmsg { 246sub fatalmsg {
203 print STDERR "FATAL: ", @_; 247 printColored('fatal', "FATAL: ", @_);
204} 248}
205 249
206# debug message 250# debug message
207sub dbgmsg { 251sub dbgmsg {
208 my $level = shift; 252 my $level = shift;
209 if ($verbose >= $level) { 253 if ($verbose >= $level) {
210 print STDERR "DEBUG[$level]: ", @_; 254 printColored('debug', "DEBUG[$level]: ", @_);
211 } 255 }
212} 256}
213 257
@@ -245,6 +289,7 @@ sub boolConverter {
245sub getOptions { 289sub getOptions {
246 my $showVersion = 0; # need version 290 my $showVersion = 0; # need version
247 my $showHelp = 0; # need help 291 my $showHelp = 0; # need help
292 my @tmpColors;
248 my @tmpTags; 293 my @tmpTags;
249 my $getOptions = GetOptions ( 294 my $getOptions = GetOptions (
250 "aggr-delta=i" => \$aggrDelta, 295 "aggr-delta=i" => \$aggrDelta,
@@ -254,6 +299,7 @@ sub getOptions {
254 "aggr-virtual!" => \$aggrVirtual, 299 "aggr-virtual!" => \$aggrVirtual,
255 "aggr-virtual-directory=s" => \$aggrVirtDir, 300 "aggr-virtual-directory=s" => \$aggrVirtDir,
256 "backup!" => \$backup, 301 "backup!" => \$backup,
302 "color=s" => \@tmpColors,
257 "comment-file=s" => \$comfile, 303 "comment-file=s" => \$comfile,
258 "config-file|c=s" => \$configFile, 304 "config-file|c=s" => \$configFile,
259 "counter-fixed-field!" => \$countFF, 305 "counter-fixed-field!" => \$countFF,
@@ -277,6 +323,7 @@ sub getOptions {
277 "rotate-thumb=i" => \$rotateThumbnail, 323 "rotate-thumb=i" => \$rotateThumbnail,
278 "tag|t=s" => \@tmpTags, 324 "tag|t=s" => \@tmpTags,
279 "trim!" => \$trim, 325 "trim!" => \$trim,
326 "use-color!" => \$useColor,
280 "use-ipc!" => \$useIPC, 327 "use-ipc!" => \$useIPC,
281 "user-comment=s" => \$userComment, 328 "user-comment=s" => \$userComment,
282