From f5110d9da15207d2af7d2a15bc84723151032205 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sun, 8 Jul 2018 13:05:09 +0900 Subject: [PATCH] Add n.post section --- README.md | 8 ++++++++ nimgen.nim | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d2d04b8..72ea01d 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,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 63e54d9..50a3849 100644 --- a/nimgen.nim +++ b/nimgen.nim @@ -888,15 +888,21 @@ proc runCfg(cfg: string) = gConfig["n.after"][afterKey]) for file in gConfig.keys(): - if file in @["n.global", "n.include", "n.exclude", "n.prepare", "n.wildcard", "n.after"]: + if file in @["n.global", "n.include", "n.exclude", + "n.prepare", "n.wildcard", "n.after", "n.post"]: continue runFile(file, gConfig[file]) - if gReset: - # Reset files - gitReset() - + 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