Browse code

Add implementation

Robert Cranston authored on 01/12/2021 00:20:49
Showing 1 changed files
... ...
@@ -9,6 +9,10 @@ each other's toes, when the native configuration language does not support
9 9
 functionality equivalent to `include config.d/*`. In essence, it is a glorified
10 10
 `cat config.d/* > config`.
11 11
 
12
+The generated file is compared against any pre-existing file, if they differ a
13
+warning is printed and the pre-existing file is moved to a backup file whose
14
+name includes a time stamp.
15
+
12 16
 [`dotd`]: https://git.rcrnstn.net/rcrnstn/dotd
13 17
 
14 18
 ## Usage
... ...
@@ -41,11 +45,13 @@ options:
41 45
 
42 46
   -c, --comment <comment>
43 47
     If non-empty, adds comments starting with <comment> that the file is
44
-    auto-generated and which fragment corresponds to which file.
48
+    auto-generated and which fragment corresponds to which file. E.g.
49
+      //
45 50
     [default: ]
46 51
 
47 52
   -g, --glob <glob>
48
-    Shell glob used to find fragment files, relative to <dir>.
53
+    Shell glob used to find fragment files, relative to <dir>. E.g
54
+      *.h
49 55
     [default: *]
50 56
 
51 57
   -v, --validate <validate>
... ...
@@ -57,10 +63,13 @@ options:
57 63
 
58 64
 ## Dependencies
59 65
 
60
-All dependencies are [POSIX][] and are highly likely to be installed by default
61
-(e.g. they all have the [Debian priority][] `required`).
66
+All dependencies are [POSIX][] (except `mktemp`, but most Unix-like systems
67
+have some version), and are highly likely to be installed by default (e.g. they
68
+all have the [Debian priority][] `required`).
62 69
 
63 70
 -   `sh` (e.g. from [`bash`][] or [`dash`][])
71
+-   `rm`, `mv`, `tail`, `date`, `mktemp` (e.g. from [`coreutils`][])
72
+-   `cmp` (e.g. from [`diffutils`][])
64 73
 -   `sed` (e.g. from [`sed`][])
65 74
 -   `awk` (e.g. from [`mawk`][])
66 75
 
... ...
@@ -68,6 +77,8 @@ All dependencies are [POSIX][] and are highly likely to be installed by default
68 77
 [Debian priority]: https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
69 78
 [`bash`]: https://packages.debian.org/bash
70 79
 [`dash`]: https://packages.debian.org/dash
80
+[`coreutils`]: https://packages.debian.org/coreutils
81
+[`diffutils`]: https://packages.debian.org/diffutils
71 82
 [`sed`]: https://packages.debian.org/sed
72 83
 [`mawk`]: https://packages.debian.org/mawk
73 84
 
Browse code

Add argument parsing

Robert Cranston authored on 28/11/2021 17:08:00
Showing 1 changed files
... ...
@@ -11,6 +11,66 @@ functionality equivalent to `include config.d/*`. In essence, it is a glorified
11 11
 
12 12
 [`dotd`]: https://git.rcrnstn.net/rcrnstn/dotd
13 13
 
14
+## Usage
15
+
16
+`dotd --help`:
17
+
18
+```
19
+dotd 1.0
20
+
21
+Generate a file from fragment files in a directory.
22
+
23
+usage:
24
+  dotd [options] [--] <file> [<dir>]
25
+  dotd -h|--help
26
+  dotd --version
27
+
28
+arguments:
29
+  <file>
30
+    File to generate. Specify - to print to stdout instead.
31
+
32
+  <dir>
33
+    Directory containing fragment files. <file>.d is used if not
34
+    specified.
35
+
36
+options:
37
+  -a, --action <action>
38
+    Action to perform on each fragment file. E.g.
39
+      printf "#include \"%s\"\n"
40
+    [default: cat]
41
+
42
+  -c, --comment <comment>
43
+    If non-empty, adds comments starting with <comment> that the file is
44
+    auto-generated and which fragment corresponds to which file.
45
+    [default: ]
46
+
47
+  -g, --glob <glob>
48
+    Shell glob used to find fragment files, relative to <dir>.
49
+    [default: *]
50
+
51
+  -v, --validate <validate>
52
+    Command to run on the (temporary) generated file. Only if the command
53
+    returns success is the file moved to its final destination. E.g.
54
+      /usr/sbin/sshd -t -f
55
+    [default: ]
56
+```
57
+
58
+## Dependencies
59
+
60
+All dependencies are [POSIX][] and are highly likely to be installed by default
61
+(e.g. they all have the [Debian priority][] `required`).
62
+
63
+-   `sh` (e.g. from [`bash`][] or [`dash`][])
64
+-   `sed` (e.g. from [`sed`][])
65
+-   `awk` (e.g. from [`mawk`][])
66
+
67
+[POSIX]: https://en.wikipedia.org/wiki/POSIX
68
+[Debian priority]: https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
69
+[`bash`]: https://packages.debian.org/bash
70
+[`dash`]: https://packages.debian.org/dash
71
+[`sed`]: https://packages.debian.org/sed
72
+[`mawk`]: https://packages.debian.org/mawk
73
+
14 74
 ## Related projects
15 75
 
16 76
 -   [Ansible][]'s [`assemble` module][].
Browse code

Add related projects to readme

Robert Cranston authored on 01/12/2021 01:20:00
Showing 1 changed files
... ...
@@ -11,6 +11,16 @@ functionality equivalent to `include config.d/*`. In essence, it is a glorified
11 11
 
12 12
 [`dotd`]: https://git.rcrnstn.net/rcrnstn/dotd
13 13
 
14
+## Related projects
15
+
16
+-   [Ansible][]'s [`assemble` module][].
17
+-   [Puppet][]'s [`concat` module][].
18
+
19
+[Ansible]: https://en.wikipedia.org/wiki/Ansible_(software)
20
+[`assemble` module]: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assemble_module.html
21
+[Puppet]: https://en.wikipedia.org/wiki/Puppet_(software)
22
+[`concat` module]: https://forge.puppet.com/modules/puppetlabs/concat
23
+
14 24
 ## License
15 25
 
16 26
 Licensed under the [ISC License][] unless otherwise noted, see the
Browse code

Add license

Robert Cranston authored on 26/11/2021 22:51:40
Showing 1 changed files
... ...
@@ -10,3 +10,11 @@ functionality equivalent to `include config.d/*`. In essence, it is a glorified
10 10
 `cat config.d/* > config`.
11 11
 
12 12
 [`dotd`]: https://git.rcrnstn.net/rcrnstn/dotd
13
+
14
+## License
15
+
16
+Licensed under the [ISC License][] unless otherwise noted, see the
17
+[`LICENSE`][] file.
18
+
19
+[ISC License]: https://choosealicense.com/licenses/isc/
20
+[`LICENSE`]: LICENSE
Browse code

Add readme

Robert Cranston authored on 26/11/2021 22:51:13
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,12 @@
1
+# [`dotd`][]
2
+
3
+Generate a file from fragment files in a directory.
4
+
5
+`dotd` is intended to be used to (re-)generate e.g. a configuration file
6
+`config` from files in a corresponding directory `config.d` where separate
7
+people or programs can place configuration fragment files without treading on
8
+each other's toes, when the native configuration language does not support
9
+functionality equivalent to `include config.d/*`. In essence, it is a glorified
10
+`cat config.d/* > config`.
11
+
12
+[`dotd`]: https://git.rcrnstn.net/rcrnstn/dotd