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
--- /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 = $config->preserve;
my $debug = $config->debug;
my $all = $config->all;
+my $nocopy = $config->nocopy;
+my $docopy = $config->docopy;
my $libdir = $config->lib;
my $ignore = $config->ignore;
my $copy = $config->copy;
@@ -78,6 +80,9 @@
die "Source and destination directories may not be the same:\n $srcdir\n"
if $srcdir eq $destdir;
+# Override --nocopy if --docopy is set
+$nocopy = 0 if ($docopy);
+
# unshift any perl5lib directories onto front of INC
unshift(@INC, @{ $config->perl5lib });
@@ -274,10 +279,15 @@
# check against copy list
foreach $check (@$copy) {
if ($base =~ /$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;
+ }
+ }
- unless ($dryrun) {
+ unless ($dryrun || $nocopy) {
copy($absfile, $dest);
if ($preserve) {
@@ -334,6 +344,8 @@
'nothing|n' => { DEFAULT => 0 },
'preserve|p' => { DEFAULT => 0 },
'all|a' => { DEFAULT => 0 },
+ 'nocopy|nc' => { DEFAULT => 0 },
+ 'docopy|dc' => { DEFAULT => 0 },
'debug|dbg' => { DEFAULT => 0 },
'define=s%',
'ignore=s@',
@@ -417,6 +429,9 @@
# recurse into any sub-directories and process files (-r)
recurse
+# don't run copy rules (-nc) useful when rebuilding all templates if a
+# sub-template changes
+nocopy
#------------------------------------------------------------------------
# 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 directives
+ -dc (--docopy) Do process copy rules (negates --nocopy)
-dbg (--debug) Debug mode
-s DIR (--src=DIR) Source directory
-d DIR (--dest=DIR) Destination directory
@@ -651,4 +668,4 @@
=head1 SEE ALSO
-L<tpage|Template::Tools::tpage>
\ No newline at end of file
+L<tpage|Template::Tools::tpage>