[Templates] ttree patch
Simon Wilcox
essuu@ourshack.com
15 Nov 2002 15:09:22 +0000
--=-wpnzrJP5exV6Mqtb10vO
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
When I'm working on a site with cascaded templates (i.e. using INCLUDE
or PROCESS) I often find I have to run ttree with the --all switch
whenever I change a sub-template to remake the templates it's included
in.
This is OK except that it always copies over all the images and other
ancillary stuff that I don't really want copied.
So I've added a --nocopy (-nc) switch to ttree which prevents the --copy
rules from running. Then, being lazy, I decided I wanted to put nocopy
in my .ttreerc to avoid putting it on the command line. So I added
--docopy (-dc) option to override nocopy.
Now, with "nocopy" in my .ttreerc, ttree -a only processes templates. To
copy over other files too, I use ttree -a -dc.
Patch attached.
Simon
--=-wpnzrJP5exV6Mqtb10vO
Content-Disposition: attachment; filename=patch-ttree
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=patch-ttree; charset=UTF-8
--- /usr/bin/ttree 2002-10-30 17:10:41.000000000 +0000
+++ /usr/bin/ttree2 2002-11-15 15:02:24.000000000 +0000
@@ -67,6 +67,8 @@
my $preserve =3D $config->preserve;
my $debug =3D $config->debug;
my $all =3D $config->all;
+my $nocopy =3D $config->nocopy;
+my $docopy =3D $config->docopy;
my $libdir =3D $config->lib;
my $ignore =3D $config->ignore;
my $copy =3D $config->copy;
@@ -78,6 +80,9 @@
die "Source and destination directories may not be the same:\n $srcdir\n"
if $srcdir eq $destdir;
=20
+# Override --nocopy if --docopy is set
+$nocopy =3D 0 if ($docopy);
+
# unshift any perl5lib directories onto front of INC
unshift(@INC, @{ $config->perl5lib });
=20
@@ -274,10 +279,15 @@
# check against copy list
foreach $check (@$copy) {
if ($base =3D~ /$check/) {
- printf " > %-32s (copied, matches /$check/)\n", $file
- if $verbose;
+ if ($verbose) {
+ if ($nocopy) {
+ printf " - %-32s (not copied, 'nocopy' set)\n", $file;
+ }else{
+ printf " > %-32s (copied, matches /$check)\n", $file;
+ }
+ }
=20
- unless ($dryrun) {
+ unless ($dryrun || $nocopy) {
copy($absfile, $dest);
=20
if ($preserve) {
@@ -334,6 +344,8 @@
'nothing|n' =3D> { DEFAULT =3D> 0 },
'preserve|p' =3D> { DEFAULT =3D> 0 },
'all|a' =3D> { DEFAULT =3D> 0 },
+ 'nocopy|nc' =3D> { DEFAULT =3D> 0 },
+ 'docopy|dc' =3D> { DEFAULT =3D> 0 },
'debug|dbg' =3D> { DEFAULT =3D> 0 },
'define=3Ds%',
'ignore=3Ds@',
@@ -417,6 +429,9 @@
# recurse into any sub-directories and process files (-r)
recurse
=20
+# don't run copy rules (-nc) useful when rebuilding all templates if a
+# sub-template changes
+nocopy
=20
#------------------------------------------------------------------------
# The 'cfg' option defines a directory in which other ttree configuration
@@ -494,6 +509,8 @@
-n (--nothing) Do nothing, just print summary (enables -v)
-v (--verbose) Verbose mode
-h (--help) This help
+ -nc (--nocopy) Only process templates, ignore --copy directiv=
es
+ -dc (--docopy) Do process copy rules (negates --nocopy)
-dbg (--debug) Debug mode
-s DIR (--src=3DDIR) Source directory
-d DIR (--dest=3DDIR) Destination directory
@@ -651,4 +668,4 @@
=20
=3Dhead1 SEE ALSO
=20
-L<tpage|Template::Tools::tpage>
\ No newline at end of file
+L<tpage|Template::Tools::tpage>
--=-wpnzrJP5exV6Mqtb10vO--