summaryrefslogtreecommitdiff
path: root/livetimes.sh
diff options
context:
space:
mode:
authorAsa Venton <asav1410@gmail.com>2019-10-23 19:17:04 +0100
committerAsa Venton <asav1410@gmail.com>2019-10-23 19:17:04 +0100
commitd3acf9b290cee0a3b820b048aafd1185657bfc70 (patch)
treee46b01f7c526f181e595a2f89209e1c60e91a9fd /livetimes.sh
parentea4b9af2111e9b3437c2ebc74f3772915c8e4676 (diff)
Tidy up comments
Diffstat (limited to 'livetimes.sh')
-rwxr-xr-xlivetimes.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/livetimes.sh b/livetimes.sh
index 5bfe7a3..f949afd 100755
--- a/livetimes.sh
+++ b/livetimes.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+# TODO: add failure check for each cURL
read stop
@@ -129,24 +130,28 @@ elif [[ "$stop" =~ ^-?[0-9]+$ ]] && [ $(echo ${#stop} == 4) ]; then
# checks if input is a valid bus route
elif [[ ${services[@]} =~ ${stop^^} ]]; then
_nextbus
-# if input has one space and a valid time then the user is probably trying to search for the next bus leaving the station for a given route and time
+# if input has one space and something resembling a time then the user is probably trying to search for the next bus leaving the station for a given route after the given time
elif [[ $(echo $stop | tr -cd ' \t' | wc -c) == 1 ]] && [[ "$stop" =~ [0-9][0-9]:[0-9][0-9] ]]; then
time=$(echo $stop | cut -d ' ' -f2)
stop=$(echo $stop | cut -d ' ' -f1)
if [[ ! "$time" =~ ^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$ ]]; then
+ # prepend help output with $error
error="Invalid time, specify time with HH:MM '!bus <route> <time>' - "
_help
elif [[ ! ${services[@]} =~ ${stop^^} ]]; then
echo $stop
echo $services
+ # prepend help output with $error
error="Invalid route provided - "
_help
else
+ # futuretime adds clarity to _nextbus output
futuretime="after $time, "
_nextbus
fi
elif [[ ${stop,,} == *"bus"* ]] || [[ ${stop,,} == *"station"* ]] || [[ ${stop,,} == *"stand"* ]]; then
_rejectbusstation
+# input not matching any of the ifs can be searched against API
else
_stopsreturn
fi