summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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