From 194f940558b494abdb16a42774ade8529f691d0f Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 4 May 2020 21:30:37 +0200 Subject: Error when jq is not found --- cargo-dot | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 "}" -- cgit v1.2.3-70-g09d2