Zaktualizuj 'weather.sh'

This commit is contained in:
Mariusz Aleszko 2018-01-25 20:46:59 +00:00
parent 2f5181237f
commit 402148c407

View File

@ -10,8 +10,12 @@ do
l) LOCATION="$OPTARG";; l) LOCATION="$OPTARG";;
d) DYNAMIC=true;; d) DYNAMIC=true;;
f) FAHRENHEIT=true;; f) FAHRENHEIT=true;;
?) echo "Niepoprawna opcja: -$OPTARG" \?) echo "Bledna opcja: -$OPTARG" >&2
exit ;; exit 1
;;
:)echo "Opcja -$OPTARG wymaga argumentu" >&2
exit 1
;;
esac esac
done done
DATE=$(date -r /tmp/$LOCATION.json +%s) DATE=$(date -r /tmp/$LOCATION.json +%s)
@ -25,23 +29,30 @@ function weather {
JSON=$(cat /tmp/$LOCATION.json) JSON=$(cat /tmp/$LOCATION.json)
clear clear
echo "Kraj $(echo $JSON | jq -r '.location.country')" if [ $FAHRENHEIT != true ]; then
echo "Miasto $(echo $JSON | jq -r '.location.name')" echo "Kraj $(echo $JSON | jq -r '.location.country')"
if $FAHRENHEIT == true echo "Miasto $(echo $JSON | jq -r '.location.name')"
then echo "Czas lokalny $(echo $JSON | jq -r '.location.localtime')"
echo "Temperatura $(echo $JSON | jq -r '.current.temp_f') °F" echo "Temperatura $(echo $JSON | jq -r '.current.temp_c') °C"
else echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_c') °C"
echo "Temperatura $(echo $JSON | jq -r '.current.temp_c') °C" echo "Predkosc wiatru $(echo $JSON | jq -r '.current.wind_kph') km/h"
fi echo "Cisnienie $(echo $JSON | jq -r '.current.pressure_mb') hPa"
if $FAHRENHEIT == true echo "Opad $(echo $JSON | jq -r '.current.precip_mm') mm"
then echo "Wilgotnosc $(echo $JSON | jq -r '.current.humidity') %"
echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_f') °F" echo "Ostatnia aktualizacja $(echo $JSON | jq -r '.current.last_updated')"
else else
echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_c') °C" echo "Kraj $(echo $JSON | jq -r '.location.country')"
fi echo "Miasto $(echo $JSON | jq -r '.location.name')"
echo "Predkosc wiatru $(echo $JSON | jq -r '.current.wind_kph') km/h" echo "Czas lokalny $(echo $JSON | jq -r '.location.localtime')"
echo "Cisnienie $(echo $JSON | jq -r '.current.pressure_mb') hPa" echo "Temperatura $(echo $JSON | jq -r '.current.temp_f') °F"
echo "Wilgotnosc $(echo $JSON | jq -r '.current.humidity') %" echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_f') °F"
echo "Predkosc wiatru $(echo $JSON | jq -r '.current.wind_mph') mph"
echo "Cisnienie $(echo $JSON | jq -r '.current.pressure_in') inHg"
echo "Opad $(echo $JSON | jq -r '.current.precip_in') inches"
echo "Wilgotnosc $(echo $JSON | jq -r '.current.humidity') %"
echo "Ostatnia aktualizacja $(echo $JSON | jq -r '.current.last_updated')"
fi
} }
if $DYNAMIC == true if $DYNAMIC == true
then then
@ -53,4 +64,16 @@ if $DYNAMIC == true
else else
weather weather
fi fi