NAME
stouch - Simple templated file creator
SYNOPSIS
stouch [options] file ...
DESCRIPTION
stouch is a simple program that creates files/directories from pre-existing templates.
By default, stouch determines the template to use by the file suffix.
Templates
A stouch template is a file or directory stored in the stouch template directory, which is determined via either the -t
option or the STOUCH_TEMPLATES
environment variable. The template file is named after the file it is templating with the '.template' suffix, ie 'raku.template'. To refer to the template, you must either create a file with the name of the template as a file suffix, or manually specify it by the -T
option.
# These both create a file using the 'raku.template' template
stouch file.raku
stouch -T=raku file
stouch can also perform basic text substitution when creating files from templates. Template files can contain substitution targets. A substitution target is a string contained in double curly brackets ('{{ ... }}') consisting of alphanumeric characters and underscores. Through the use of the -s
option, these substitution targets can be replaced by another string. Consult the documentation for the -s
option below for more information.
When generating a templated directory, stouch will recreate the template's directory structure and perform text substitution on each text file in said directory.
OPTIONS
-T|--template=template
Instead of determining the template to use based on a file's suffix, use template.
When using this option with multiple files, all files will use the same template.
-l|--targets=template
Print list of substitution targets in template.
-s|--substitute=params
Specify parameters to use for text substitution when generating files. params is a string that contains a comma-seperated list of substitutions to perform. Each substitution is the name of the substitution target and the text that will replace the target seperated by a fat arrow (=>).
For example, say you have the following template:
This is a {{type}} file.
It does {{whatever}}.
And you generate a file from it using the following option:
-s="type => text, whatever => stuff"
The generated file will look like this:
This is a text file.
It does stuff.
Note that any leading/trailing whitespace for substitution targets and replacements is trimmed.
-t|--template-dir=dir
Specify the directory where stouch will look for templates in. Defaults to the the STOUCH_TEMPLATES
environment variable. One of those must be specified for stouch to work.
-h|--help
Print this manual.
-u|--usage
Print usage message.
-v|--version
Print version and copyright information.
ENVIRONMENT
AUTHOR
Written by Samuel Young, samyoung12788@gmail.com.
COPYRIGHT
Copyright 2024, Samuel Young
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.