diff options
author | Andy Shevchenko <andy@smile.org.ua> | 2006-08-22 07:18:22 +0000 |
---|---|---|
committer | Andy Shevchenko <andy@smile.org.ua> | 2006-08-22 07:18:22 +0000 |
commit | 165a725a6cf238b9bf25e858a1c2af566e7c9655 (patch) | |
tree | 5b8b813b7c8b273b83862eb472d8f9248e65d458 | |
parent | f494599aecd21266e9852085b3b73cea48e760bd (diff) | |
download | renrot-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-- | ChangeLog | 5 | ||||
-rw-r--r-- | NEWS | 12 | ||||
-rw-r--r-- | etc/colors.conf | 13 | ||||
-rw-r--r-- | etc/renrot.conf | 3 | ||||
-rwxr-xr-x | renrot | 129 | ||||
-rw-r--r-- | renrot.spec | 5 |
6 files changed, 153 insertions, 14 deletions
@@ -1,4 +1,8 @@ | |||
1 | $Log$ | 1 | $Log$ |
2 | Revision 1.148.2.4 2006/08/22 07:18:22 andy | ||
3 | The colorization for output has been implemented, the options --use-color and | ||
4 | --color were added. | ||
5 | |||
2 | Revision 1.148.2.3 2006/08/19 10:59:19 andy | 6 | Revision 1.148.2.3 2006/08/19 10:59:19 andy |
3 | Release as 0.23. | 7 | Release as 0.23. |
4 | 8 | ||
@@ -605,3 +609,4 @@ Id keyword is added to renrot file. | |||
605 | 609 | ||
606 | Revision 1.1 2005/10/17 13:39:38 zeus | 610 | Revision 1.1 2005/10/17 13:39:38 zeus |
607 | ChangeLog file is added. Its the very begining. | 611 | ChangeLog file is added. Its the very begining. |
612 | |||
@@ -1,12 +1,12 @@ | |||
1 | * 0.23 * | 1 | * 0.23 * |
2 | 2 | ||
3 | The additional template sequences %C, %O, and %o had been added. They are | 3 | The additional template sequences %C, %O, and %o had been added. They |
4 | represented the original filename counter, base part and full copy of the | 4 | represent the original filename counter, base part, and full copy of the |
5 | original filename respectively. A new tag RenRotFileNameOriginal is writing | 5 | original filename respectively. A new tag, RenRotFileNameOriginal, is written |
6 | after first pass by renrot. On a Win32 platform the home path is taken from | 6 | after the first pass by renrot. On the Win32 platform, the home path is taken |
7 | the environment variable USERPROFILE instead of HOME. The IPC support for | 7 | from the environment variable USERPROFILE instead of HOME. The IPC support for |
8 | rotating thumbnails has been added. The output messages of the usage function | 8 | rotating thumbnails has been added. The output messages of the usage function |
9 | had been reformatted. | 9 | have 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 | ||
@@ -12,6 +12,11 @@ use Time::Local; | |||
12 | use Image::ExifTool; | 12 | use Image::ExifTool; |
13 | use Getopt::Long; | 13 | use Getopt::Long; |
14 | 14 | ||
15 | use Term::ANSIColor; | ||
16 | |||
17 | $Term::ANSIColor::AUTORESET = 1; | ||
18 | $Term::ANSIColor::EACHLINE = "\n"; | ||
19 | |||
15 | our $VERSION = "0.23"; # the version of this script | 20 | our $VERSION = "0.23"; # the version of this script |
16 | my $maxVerbosity = 4; # our max verbosity level (internal) | 21 | my $maxVerbosity = 4; # our max verbosity level (internal) |
17 | 22 | ||
@@ -79,6 +84,7 @@ my $aggrTemplate; # template for the files aggregation taken from CLI | |||
79 | my $aggrVirtual; # flag to do links instead real file moving while aggregation | 84 | my $aggrVirtual; # flag to do links instead real file moving while aggregation |
80 | my $aggrVirtDir; # directory name for virtual aggregation | 85 | my $aggrVirtDir; # directory name for virtual aggregation |
81 | my $backup = 1; # make or not a backup of the original files | 86 | my $backup = 1; # make or not a backup of the original files |
87 | my %colorsFromCli; # colors are got from CLI | ||
82 | my $comfile; # file with commentary | 88 | my $comfile; # file with commentary |
83 | my $configFile; # configuration file | 89 | my $configFile; # configuration file |
84 | my $countFF = 1; # use fixed field for counter | 90 | my $countFF = 1; # use fixed field for counter |
@@ -101,6 +107,7 @@ my $rotateAngle; # define the angle to rotate on 90, 180 or 270 | |||
101 | my $rotateThumbnail; # define the angle to rotate on 90, 180 or 270 | 107 | my $rotateThumbnail; # define the angle to rotate on 90, 180 or 270 |
102 | my %tagsFromCli; # tags are got from CLI | 108 | my %tagsFromCli; # tags are got from CLI |
103 | my $trim; # jpegtran -trim | 109 | my $trim; # jpegtran -trim |
110 | my $useColor; # colorized output | ||
104 | my $useIPC; # rotate thumbnail via pipe | 111 | my $useIPC; # rotate thumbnail via pipe |
105 | my $userComment; # text to put into UserComment tag | 112 | my $userComment; # text to put into UserComment tag |
106 | my $verbose = 0; # verbosity of output | 113 | my $verbose = 0; # verbosity of output |
@@ -173,41 +180,78 @@ my %rotorientrev = reverse %rotorient; | |||
173 | my %incFiles; # hash of included files while parsing configuration file | 180 | my %incFiles; # hash of included files while parsing configuration file |
174 | 181 | ||
175 | my @multOpts = ( | 182 | my @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 | # | ||
193 | my %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 | ||
203 | sub 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 |
182 | sub procmsg { | 217 | sub 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 |
187 | sub infomsg { | 231 | sub infomsg { |
188 | print STDERR @_; | 232 | printColored('info', @_); |
189 | } | 233 | } |
190 | 234 | ||
191 | # warning message | 235 | # warning message |
192 | sub warnmsg { | 236 | sub warnmsg { |
193 | print STDERR "Warning: ", @_; | 237 | printColored('warning', "Warning: ", @_); |
194 | } | 238 | } |
195 | 239 | ||
196 | # error message | 240 | # error message |
197 | sub errmsg { | 241 | sub errmsg { |
198 | print STDERR "ERROR: ", @_; | 242 | printColored('error', "ERROR: ", @_); |
199 | } | 243 | } |
200 | 244 | ||
201 | # fatal message | 245 | # fatal message |
202 | sub fatalmsg { | 246 | sub fatalmsg { |
203 | print STDERR "FATAL: ", @_; | 247 | printColored('fatal', "FATAL: ", @_); |
204 | } | 248 | } |
205 | 249 | ||
206 | # debug message | 250 | # debug message |
207 | sub dbgmsg { | 251 | sub 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 { | |||
245 | sub getOptions { | 289 | sub 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 |