summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 "}"