summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-05-04 21:30:37 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-05-04 21:30:52 +0200
commit194f940558b494abdb16a42774ade8529f691d0f (patch)
treecfd88b146acaf70d09b5667a466e0b16dd428647
parent154d0def16256fcb0ee861ec7a47fda7aecd9d91 (diff)
Error when jq is not foundHEADmaster
-rwxr-xr-xcargo-dot9
1 files changed, 8 insertions, 1 deletions
diff --git a/cargo-dot b/cargo-dot
index 571a47f..630a307 100755
--- a/cargo-dot
+++ b/cargo-dot
@@ -1,4 +1,11 @@
#!/usr/bin/env bash
+JQ="$(command -v jq)"
+if [[ $? -ne 0 ]]; then
+ echo >&2 "jq not found, please install jq"
+ exit 1
+fi
+
echo "digraph G {"
-cargo metadata --format-version=1 | jq -r '.packages[] | "\"" + .id[0:.id|index(" ")] + "\" -> \"" + .dependencies[].name + "\";"'
+cargo metadata --format-version=1 |
+ "$JQ" -r '.packages[] | "\"" + .id[0:.id|index(" ")] + "\" -> \"" + .dependencies[].name + "\";"'
echo "}"