diff --git a/snag.json b/snag.json index 0cdee67..518738f 100644 --- a/snag.json +++ b/snag.json @@ -4,12 +4,11 @@ "email": "user@site.domain", "author": "snag", "presnag": [ - "/usr/bin/ls", - "/usr/local/bin/script.sh" + "echo $(which ls)", + "pwd" ], "postsnag": [ - "/usr/bin/ls", - "/usr/local/bin/script.sh" + "/usr/bin/ls" ], "rules": { "tracking": [ diff --git a/source/snag/config/config.d b/source/snag/config/config.d index 635cc6d..e9e0ca2 100644 --- a/source/snag/config/config.d +++ b/source/snag/config/config.d @@ -17,6 +17,8 @@ class SnagConfig { private string _author; private string[] _tracking; private string[] _ignore; + private string[] _presnag; + private string[] _postsnag; this(string configFile) { string jsonText; @@ -119,6 +121,22 @@ class SnagConfig { _ignore = rules["ignore"].array.map!(item => item.str).array; } } + + if ("presnag" in jsonData) { + if (jsonData["presnag"].type != JSONType.array) + throw new SnagConfigException( + "The \"presnag\" parameter must be an array containing a set of commands" + ); + _presnag = jsonData["presnag"].array.map!(item => item.str).array; + } + + if ("postsnag" in jsonData) { + if (jsonData["postsnag"].type != JSONType.array) + throw new SnagConfigException( + "The \"postsnag\" parameter must be an array containing a set of commands" + ); + _postsnag = jsonData["postsnag"].array.map!(item => item.str).array; + } } @property string git() const { return _git; } @@ -127,4 +145,6 @@ class SnagConfig { @property string author() const { return _author; } @property const(string[]) tracking() const { return _tracking; } @property const(string[]) ignore() const { return _ignore; } + @property const(string[]) presnag() const { return _presnag; } + @property const(string[]) postsnag() const { return _postsnag; } }