-
Notifications
You must be signed in to change notification settings - Fork 1
/
pcal.sh
50 lines (44 loc) · 821 Bytes
/
pcal.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! usr/bin/env bash
set -euo pipefail
set -o errtrace
help()
{
man pcal
exit 2
}
while getopts ef:o:lpPjJmMg:O:G:bs::F:AEX:Y:x:y:t::d::n::L:C:R:N:D:U:B:\#:SkKwIcHqz:huva:r::T::W:: flag
do
case "${flag}" in
-c | --city1 )
city1="$2"
shift 2
;;
-d | --city2 )
city2="$2"
shift 2
;;
-h | --help)
help
;;
--)
shift;
break
;;
*)
echo "Unexpected option: $1"
help
;;
esac
done
if [ "$city1" ] && [ -z "$city2" ]
then
curl -s "https://wttr.in/${city1}"
elif [ -z "$city1" ] && [ "$city2" ]
then
curl -s "https://wttr.in/${city2}"
elif [ "$city1" ] && [ "$city2" ]
then
diff -Naur <(curl -s "https://wttr.in/${city1}" ) <(curl -s "https://wttr.in/${city2}" )
else
curl -s https://wttr.in
fi