summaryrefslogtreecommitdiffstats
path: root/bin/cac-get-server-by
blob: b6d6b4ba3f3b615189cd32c6928a790b5a1543b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! /bin/sh
set -euf

cac-listservers \
  | jq \
    --arg k "$1" \
    --arg v "$2" \
    '
      map(select(.[$k]==$v)) |
      if (. | length) == 0 then
        null
      elif (. | length) == 1 then
        .[0]
      else
        .
      end
    '