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";;
d) DYNAMIC=true;;
f) FAHRENHEIT=true;;
?) echo "Niepoprawna opcja: -$OPTARG"
exit ;;
\?) echo "Bledna opcja: -$OPTARG" >&2
exit 1
;;
:)echo "Opcja -$OPTARG wymaga argumentu" >&2
exit 1
;;
esac
done
DATE=$(date -r /tmp/$LOCATION.json +%s)
@ -25,23 +29,30 @@ function weather {
JSON=$(cat /tmp/$LOCATION.json)
clear
echo "Kraj $(echo $JSON | jq -r '.location.country')"
echo "Miasto $(echo $JSON | jq -r '.location.name')"
if $FAHRENHEIT == true
then
echo "Temperatura $(echo $JSON | jq -r '.current.temp_f') °F"
else
echo "Temperatura $(echo $JSON | jq -r '.current.temp_c') °C"
fi
if $FAHRENHEIT == true
then
echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_f') °F"
else
echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_c') °C"
fi
echo "Predkosc wiatru $(echo $JSON | jq -r '.current.wind_kph') km/h"
echo "Cisnienie $(echo $JSON | jq -r '.current.pressure_mb') hPa"
echo "Wilgotnosc $(echo $JSON | jq -r '.current.humidity') %"
if [ $FAHRENHEIT != true ]; then
echo "Kraj $(echo $JSON | jq -r '.location.country')"
echo "Miasto $(echo $JSON | jq -r '.location.name')"
echo "Czas lokalny $(echo $JSON | jq -r '.location.localtime')"
echo "Temperatura $(echo $JSON | jq -r '.current.temp_c') °C"
echo "Temperatura odczuwalna $(echo $JSON | jq -r '.current.feelslike_c') °C"
echo "Predkosc wiatru $(echo $JSON | jq -r '.current.wind_kph') km/h"
echo "Cisnienie $(echo $JSON | jq -r '.current.pressure_mb') hPa"
echo "Opad $(echo $JSON | jq -r '.current.precip_mm') mm"
echo "Wilgotnosc $(echo $JSON | jq -r '.current.humidity') %"
echo "Ostatnia aktualizacja $(echo $JSON | jq -r '.current.last_updated')"
else
echo "Kraj $(echo $JSON | jq -r '.location.country')"
echo "Miasto $(echo $JSON | jq -r '.location.name')"
echo "Czas lokalny $(echo $JSON | jq -r '.location.localtime')"
echo "Temperatura $(echo $JSON | jq -r '.current.temp_f') °F"
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
then
@ -54,3 +65,15 @@ else
weather
fi