tptree - a very humble imitation of ttree from TT2
Ask the version number to the script itself, calling:
shell$ tptree --version
tptree [--usage] [--help] [--man] [--version] tptree [--source|--src|-s directory] [--dest|--dst|-d directory] [--process|-p regex] [--verbose|-v] [--variables|-V] [--define|-D item] [--edefine|--eval-define|-E item] [--hdefine|--hex-define|-H|-X item] [--sdefine|--storable-define|-S item] [--sstdin|--storable-stdin|-i]
shell$ tptree shell$ tptree --src source --dst /path/to/dst --define ciao='a tutti'
This simple script tries to capture what I've personally found to be 90% of the useful functionality in TT2: recursing into a given file tree, apply the transformations with the templating system, and put the result into a directory tree analogous to the starting one, but where I desire.
As a minimum, you have to provide a source directory and a destination. Every output directory that's not already there will be created, so the destination directory needs not to be previously created.
During processing, you can decide which files should be included by providing a selection regular expression through
One aspect where tptree goes quite on its own way is variable passing. While TT2's ttree is bound to simple
variable=value paradigm, tptree offers a wide variety for both escaping/encoding the variables, or get them via standard input (<--sstdin|--storable-stdin|-i>).
Parameter passing options are discussed in a section by themselves, to be found later in this document.
set the destination directory root.
print a somewhat more verbose help, showing usage, this description of the options and some examples from the synopsis.
print out the full documentation for the script.
set the given regex as a regular expression to be matched on each filename found in the hierarchy. If matches, the file is "executed", otherwise.
set the source directory for directory root.
print a concise usage line and exit.
print a dump of the configured variables.
output some debug messages during execution.
print the version of the script.
There are three variables-setting facilities that can be used on the command line:
set name as value
evaluate expression and set name to the result. So, for example you can say:
name='[qw(ciao a tutti)]'
and get name set to an anonymous array containing three elements (guess which?)
convert hexvalue back to unencoded form, using
pack's template 'H*', then set as the value of variable
convert storable-hex back into binary data (using 'H*'), then retrieve a value using Storable.
Last, but not least, a set of variables embedded into a hash ref encoded with Storable can be read from the standard input:
get configuration from standard input, decoding it using Storable.
tptree requires no configuration files or environment variables.
None, apart Template::Perlish. Unless it has been embedded in this very file.
No bugs have been reported.
Please report any bugs or feature requests through http://rt.cpan.org/
Copyright (c) 2008-2015 by Flavio Poletti
This program is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.