From 5f746c33b71d8413111084e82f5aec1df47bd033 Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Wed, 28 May 2025 02:27:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20pre=20=D0=B8=20post=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?snag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snag.json | 7 +++---- source/snag/config/config.d | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) 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; } }