README.md
8d85569f
 # [`dotd`][]
 
 Generate a file from fragment files in a directory.
 
 `dotd` is intended to be used to (re-)generate e.g. a configuration file
 `config` from files in a corresponding directory `config.d` where separate
 people or programs can place configuration fragment files without treading on
 each other's toes, when the native configuration language does not support
 functionality equivalent to `include config.d/*`. In essence, it is a glorified
 `cat config.d/* > config`.
 
a486e739
 The generated file is compared against any pre-existing file, if they differ a
 warning is printed and the pre-existing file is moved to a backup file whose
 name includes a time stamp.
 
8d85569f
 [`dotd`]: https://git.rcrnstn.net/rcrnstn/dotd
bf567322
 
14afd48f
 ## Usage
 
 `dotd --help`:
 
 ```
 dotd 1.0
 
 Generate a file from fragment files in a directory.
 
 usage:
   dotd [options] [--] <file> [<dir>]
   dotd -h|--help
   dotd --version
 
 arguments:
   <file>
     File to generate. Specify - to print to stdout instead.
 
   <dir>
     Directory containing fragment files. <file>.d is used if not
     specified.
 
 options:
   -a, --action <action>
     Action to perform on each fragment file. E.g.
       printf "#include \"%s\"\n"
     [default: cat]
 
   -c, --comment <comment>
     If non-empty, adds comments starting with <comment> that the file is
a486e739
     auto-generated and which fragment corresponds to which file. E.g.
       //
14afd48f
     [default: ]
 
   -g, --glob <glob>
a486e739
     Shell glob used to find fragment files, relative to <dir>. E.g
       *.h
14afd48f
     [default: *]
 
   -v, --validate <validate>
     Command to run on the (temporary) generated file. Only if the command
     returns success is the file moved to its final destination. E.g.
       /usr/sbin/sshd -t -f
     [default: ]
 ```
 
 ## Dependencies
 
a486e739
 All dependencies are [POSIX][] (except `mktemp`, but most Unix-like systems
 have some version), and are highly likely to be installed by default (e.g. they
 all have the [Debian priority][] `required`).
14afd48f
 
 -   `sh` (e.g. from [`bash`][] or [`dash`][])
a486e739
 -   `rm`, `mv`, `tail`, `date`, `mktemp` (e.g. from [`coreutils`][])
 -   `cmp` (e.g. from [`diffutils`][])
14afd48f
 -   `sed` (e.g. from [`sed`][])
 -   `awk` (e.g. from [`mawk`][])
 
 [POSIX]: https://en.wikipedia.org/wiki/POSIX
 [Debian priority]: https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
 [`bash`]: https://packages.debian.org/bash
 [`dash`]: https://packages.debian.org/dash
a486e739
 [`coreutils`]: https://packages.debian.org/coreutils
 [`diffutils`]: https://packages.debian.org/diffutils
14afd48f
 [`sed`]: https://packages.debian.org/sed
 [`mawk`]: https://packages.debian.org/mawk
 
b3793362
 ## Related projects
 
 -   [Ansible][]'s [`assemble` module][].
 -   [Puppet][]'s [`concat` module][].
 
 [Ansible]: https://en.wikipedia.org/wiki/Ansible_(software)
 [`assemble` module]: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assemble_module.html
 [Puppet]: https://en.wikipedia.org/wiki/Puppet_(software)
 [`concat` module]: https://forge.puppet.com/modules/puppetlabs/concat
 
bf567322
 ## License
 
 Licensed under the [ISC License][] unless otherwise noted, see the
 [`LICENSE`][] file.
 
 [ISC License]: https://choosealicense.com/licenses/isc/
 [`LICENSE`]: LICENSE