Usage
Universal Text Pre-Processor ('utpp') is a tool for preprocessing any file
Usage: utpp [options] <files> [variables]
Options:
--help Show help [boolean]
-V, --version Show version number [boolean]
-o, --output write to output file [string]
-c, --check checks the file's syntax only [boolean] [default: false]
-v, --verbose show more debug logs [boolean] [default: false]
-p, --print prints the output to stdout instead of files [boolean]
-q, --quiet makes the preprocessor quiet [boolean] [default: false]
--ignore glob pattern to ignore files [string] [default: ""]
--encoding encoding of the input file [string] [default: "utf8"]
--no-eval disables eval function [boolean]
--no-files disables inclusion from files [boolean]
--no-urls disables inclusion from urls [boolean]
--no-env disables inclusion of environment variables [boolean]
--no-template disables template replacement [boolean]
--no-vars disables variables replacement [boolean]
--ignore-unkown ignores unknown commands to improve compat [boolean]
--safe enables safe mode: only process marked files [boolean]
Examples:
utpp -o out.txt input.txt runs the preprocessor on input.txt and write output
to out.txt
utpp input.txt foo=bar runs the preprocessor on input.txt and sets
variable foo to bar
utpp "*/**" foo=bar runs the preprocessor on all files in the current &
sub directory and sets variable foo to bar
utpp -c input.txt validates the syntax of input.txt file
for more info and support visit https://github.com/adrianschubek/utpp
You can use any glob pattern as files argument to select multiple files.
For example utpp "*/**" foo=bar
will run the preprocessor on all files in the current directory and all subdirectories and set the variable foo
to bar
.
Or utpp "foo.txt;bar.tex;baz.html"
will run the preprocessor on foo.txt
, bar.tex
and baz.html
.
Show this help page by running utpp
.
Running it on a single file
utpp input.txt
This will run the preprocessor on input.txt
and write the output to input.txt
as well.
If you want to write the output to a different file, use the -o
option:
utpp -o output.txt input.txt
This will run the preprocessor on input.txt
and write the output to output.txt
. The input file will not be modified.
And if you want to print the output to stdout, use the -p
option:
utpp -p input.txt
This will run the preprocessor on input.txt
and print the output to stdout. This is useful if you want to pipe the output to another program.
The input file will not be modified.
Running it on multiple files
utpp "*/**"
This will run the preprocessor on all files in the current directory and all subdirectories and write the output to the same files.
If you want to write the output to stdout, use the -p
option:
utpp -p "*/**"
The -o
option is not supported when running on multiple files.
If you specify a wide glob pattern (such as "/**") you could run in on files you did not intend to run it on, which may result in errors. Make sure to read the Safe Mode option.
Using mutiple patterns
You can specify multiple glob patterns by separating them with a semicolon ; :
utpp "foo.txt;bar.tex;baz.html"
This will run the preprocessor on foo.txt
, bar.tex
and baz.html
and write the output to the same files.
Ignoring files
You can specify a glob pattern to ignore files by using the --ignore
option:
utpp --ignore "*/**/*.txt" "*/**"
This will run the preprocessor on all files in the current directory and all subdirectories except for files ending with .txt
.
By seperating the patterns with a semicolon ; you can specify multiple patterns to ignore.
Setting variables
You can set variables by specifying them after the files argument:
utpp input.txt foo=bar
This will run the preprocessor on input.txt
and set the variable foo
to bar
.
You can also set multiple variables by leaving a space between them foo=bar baz=qux
.
When setting a value which contain spaces, you need to wrap it in quotes: foo="bar baz"
.
Troubleshooting
Enable verbose mode by using the -v
option:
utpp -v input.txt
This will print debug logs to the console. Checkout Safe Mode for further troubleshooting.
Checking the syntax only
You can check the syntax of a file without running the preprocessor by using the -c
option:
utpp -c input.txt
This will check the syntax of input.txt
and print any errors to the console. Combine it with -v
to print debug logs as well.
Silent mode
You can make the preprocessor silent by using the -q
option:
utpp -q input.txt
This wil supress any output to the console except errors.
You can also silence these errors and making utpp completly quiet by pipeing the output to /dev/null
:
utpp -q input.txt > /dev/null 2>&1