From f8e1e63e5b0389d610db74262c7fb3e0d8a919af Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Thu, 3 Mar 2022 10:59:37 +0100
Subject: [PATCH] colored output if jq is found

---
 dns-api.sh | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/dns-api.sh b/dns-api.sh
index bef15ec..7f9b395 100755
--- a/dns-api.sh
+++ b/dns-api.sh
@@ -7,11 +7,15 @@
 # requires
 #  - curl
 #
+# optional:
+#  - jq
+#
 # ----------------------------------------------------------------------
 # DOC: https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf
 # ----------------------------------------------------------------------
 # 2021-01-20  v0.0  <axel.hahn@iml.unibe.ch>
 # 2022-01-14  v1.0  <axel.hahn@iml.unibe.ch>  1st public version
+# 2022-03-03  v1.1  <axel.hahn@iml.unibe.ch>  colored output if jq is found
 # ======================================================================
 
 
@@ -36,9 +40,9 @@ fi
 relUrl="$1"
 
 # ----- make curl request
-echo "; === DNS API"
-echo "; method $method"
-echo "; rel url ${relUrl}"
-echo "; ----------------------------------------------------------------------"
+echo "; === DNS API :: $method ${relUrl}"
+
+curl -u $myauth -X $method "${mybaseurl}${relUrl}" 2>/dev/null \
+    | ( if which jq >/dev/null 2>&1; then jq; else cat; echo ; fi )
 
-curl -u $myauth -X $method "${mybaseurl}${relUrl}" 2>/dev/null
+# ----------------------------------------------------------------------
\ No newline at end of file
-- 
GitLab