Usage: cat {input-file} | ./template-replace --key val --key2 val2 ... > {output-file}
app.conf.template
[section]
location=${location}
command-line
cat app.conf.template | ./template-replace --location "/opt/program/" > build/app.conf
build/app.conf
[section]
location=/opt/program
$TEMPLATE_REPLACE_STYLE
cat input | TEMPLATE_REPLACE_STYLE="DEFAULT" ./template-replace --key value > output
styles:
DEFAULT
/BASH
${key}
DOUBLE
{{key}}
SINGLE
{key}
you can directly invoke commands and insert the output into the template
note: you can't use formatter on the output
${$:echo "Hello World"}
There are certain default variables
name | value |
---|---|
today | date today as iso-format string |
now | time now as iso-format string |
otherwise you can use shell variables (${$shell-variable}
)
or variables provided via --key value
as command-line arguments
you can specify a formatting option with ${key:fmt opt1 opt2 ...}
formatting options:
Escapes special characters ("
|'
|\t
|\n
|...) in a string.
${key:escape}
Format the value to a date
The value can either be a timestamp or either $TEMPLATE_REPLACE_STRPTIME
(if available) or iso-format
${key:date [fmt]}
See here for information about the format.
${key:align left|center|right size [fillchar]}
Removes any common leading whitespace from every line in the text.
${key:dedent}
Adds 'prefix' to the beginning of every line in the text.
${key:indent [prefix]}
removes spaces and newlines on both sides or left/right
${key:trim [left|both|right]}
removes spaces and newlines one the left side
Alias for ${key:trim left}
${key:ltrim}
removes spaces and newlines one the right side
Alias for ${key:trim right}
${key:rtrim}