aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-08 13:05:09 +0900
committerJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-10 15:15:00 +0900
commitab3185b611c138ad32c7149ba5260ba67bf0fb4a (patch)
treea6b8791ba1b9b679a4ef0235dc034f5cf3e73fbb
parent84894bfa0c2eb82e719c73a512c07d0ca595aff1 (diff)
downloadnimgen-ab3185b611c138ad32c7149ba5260ba67bf0fb4a.tar.gz
nimgen-ab3185b611c138ad32c7149ba5260ba67bf0fb4a.zip
Add n.post section
-rw-r--r--README.md8
-rw-r--r--nimgen.nim13
2 files changed, 20 insertions, 1 deletions
diff --git a/README.md b/README.md
index 40f7556..6bc1cd1 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,14 @@ The following keys can be used to prepare dependencies such as downloading ZIP f
```copy``` = copy a file to another location. Preferred over moving to preserve original. Comma separate for multiple entries. E.g. copy = "output/config.h.in=output/config.h"
+_[n.post]_
+
+This section is the same as the prepare section, but for performing actions after the project has been processed.
+
+```reset``` = whether or not to perform a git reset on all files after processing [default: false]
+
+```execute``` = command to run after processing
+
_[n.wildcard]_
File wildcards such as *.nim, ssl*.h, etc. can be used to perform tasks across a group of files. This is useful to define common operations such as global text replacements without having to specify an explicit section for every single file. These operations will be performed on every matching file that is defined as a _sourcefile_ or recursed files. Only applies on source files following the wildcard declarations.
diff --git a/nimgen.nim b/nimgen.nim
index c132fe1..fedbee5 100644
--- a/nimgen.nim
+++ b/nimgen.nim
@@ -797,11 +797,22 @@ proc runCfg(cfg: string) =
gConfig["n.wildcard"][wild])
for file in gConfig.keys():
- if file in @["n.global", "n.include", "n.exclude", "n.prepare", "n.wildcard"]:
+ if file in @["n.global", "n.include", "n.exclude",
+ "n.prepare", "n.wildcard", "n.post"]:
continue
runFile(file, gConfig[file])
+ if gConfig.hasKey("n.post"):
+ for post in gConfig["n.post"].keys():
+ let (key, val) = getKey(post)
+ if val == true:
+ let postVal = gConfig["n.post"][post]
+ if key == "reset":
+ gitReset()
+ elif key == "execute":
+ discard execProc(postVal)
+
# ###
# Main loop