summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2019-08-18 14:25:27 -0400
committerDave Henderson <dhenderson@gmail.com>2019-08-18 14:25:27 -0400
commiteb8c563fcf62e2cc6b072550d3fe7cfb390f69a6 (patch)
tree17b77547355d962af9e7761ee500e78300bdb39f /docs
parentb4b82904d31d3166a8e40b4b88ebb02eea8641aa (diff)
Adding --include flag
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/content/usage.md14
1 files changed, 10 insertions, 4 deletions
diff --git a/docs/content/usage.md b/docs/content/usage.md
index 0ed547c4..2e85a688 100644
--- a/docs/content/usage.md
+++ b/docs/content/usage.md
@@ -91,15 +91,15 @@ The value must be an octal integer in the standard UNIX `chmod` format, i.e. `64
**Note:** `--chmod` is not currently supported on Windows. Behaviour is undefined, but will likely not change file permissions at all.
-### `--exclude`
+### `--exclude` and `--include`
-When using the [`--input-dir`](#input-dir-and-output-dir) argument, it can be useful to exclude certain files from being processed. You can use `--exclude` to achieve this. It takes a [`.gitignore`][]-style pattern, and any files matching the pattern will be excluded. You can also repeat the argument to provide a series of patterns to be excluded.
+When using the [`--input-dir`](#input-dir-and-output-dir) argument, it can be useful to filter which files are processed. You can use `--exclude` and `--include` to achieve this. The `--exclude` flag takes a [`.gitignore`][]-style pattern, and any files matching the pattern will be excluded. The `--include` flag is effectively the opposite of `--exclude`. You can also repeat the arguments to provide a series of patterns to be excluded/included.
-Patterns provided with `--exclude` are matched relative to the input directory.
+Patterns provided with `--exclude`/`--include` are matched relative to the input directory.
_Note:_ These patterns are _not_ treated as filesystem globs, and so a pattern like `/foo/bar.json` will match relative to the input directory, not the root of the filesystem as they may appear!
-Example:
+Examples:
```console
$ gomplate --exclude example/** --exclude *.png --input-dir in/ --output-dir out/
@@ -107,6 +107,12 @@ $ gomplate --exclude example/** --exclude *.png --input-dir in/ --output-dir out
This will stop all files in the `in/example` directory from being processed, as well as all `.png` files in the `in/` directory.
+```console
+$ gomplate --include *.tmpl --exclude foo*.tmpl --input-dir in/ --output-dir out/
+```
+
+This will cause only files ending in `.tmpl` to be processed, except for files with names beginning with `foo`: `template.tmpl` will be included, but `foo-template.tmpl` will not.
+
#### `.gomplateignore` files
You can also use a file named `.gomplateignore` containing one exclude pattern on each line. This has the same syntax as a [`.gitignore`][] file.