Stouch
; }
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 -d option or the
STOUCH_TEMPLATES environment variable. If neither of those are specified,
stouch will default to ~/.stouch. 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. stouch
also supports the use of substitution targets in file paths, eg:
# This will create a file named foo.raku
stouch -s "script => foo" {{script}}.raku
When generating a templated directory, stouch will recreate the template's directory structure and perform text substitution on each text file in said directory. File names in a template directory that contain a substitution target are able to be replaced as well.
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.
-d|--template-dir=dir
Specify the directory where stouch will look for templates in. Defaults to the the
STOUCH_TEMPLATESenvironment variable if specified, or~/.stouchif not.-h|--help
Print usage message.
-m|--man
Display manual.
-v|--version
Print version and copyright information.
ENVIRONMENT
STOUCH_TEMPLATES
Directory where stouch will look for templates in.
AUTHOR
Written by Samuel Young, [email protected].
COPYRIGHT
Copyright 2024-2025, Samuel Young
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.