File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # pcc - POTA country code finder
4
+ #
5
+ # pcc without the -n switch will search for a country code
6
+ # pcc with the -n switch will search by country name
7
+ #
8
+ # all inputs are case insensitive for either search
9
+ #
10
+ # the output will be 3 lines: country prefix, country name, number of parks in the pota database
11
+ #
12
+ # NOTE: this uses the jq utility.
13
+
14
+ if [ -z " $1 " ]; then
15
+ echo ' usage: pcc [ country-code | country-name ]'
16
+ exit 0
17
+ fi
18
+
19
+ if [ ! $( which jq) ]; then
20
+ echo " you need jq: do sudo apt install jq"
21
+ exit 1
22
+ fi
23
+
24
+ curl -s https://api.pota.app/programs/locations > locations.json
25
+ cat locations.json | jq -r " .[] | select((.prefix | test(\" $1 \" ; \" i\" )) or (.name | test(\" $1 \" ;\" i\" ))) | [.prefix, .name] | @tsv" | sort
26
+ rm -f locations.json
You can’t perform that action at this time.
0 commit comments