#!/usr/bin/env fish set countrycode 'de' set lang 'en-US' set limit 1 set q "$argv[1]" set raw 'false' set jqstr '.lat, .lon, .display_name' # if run in a terminal, one line per output if test -t 1 set jqstr '"\(.lat) \(.lon) \(.display_name)"' set limit 5 end set i 1 while test $i -le (count $argv) switch $argv[$i] case '-n' set i (math $i + 1) set limit $argv[$i] case '-c' set i (math $i + 1) set countrycode $argv[$i] case '-r' set raw 'true' case '*' set q $p $argv[$i] end set i (math $i + 1) end set result (curl -s "https://nominatim.openstreetmap.org/search?q=$q&format=json&limit=$limit&countrycodes=$countrycode&accept-language=$lang") if test "$raw" = 'true' echo $result | python -m json.tool else echo $result | jq -r ".[] | $jqstr" end