summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjulien2009-07-07 16:38:54 +0200
committerjulien2009-07-07 16:38:54 +0200
commit24e26c2b661c603c07e50bb1160ce0e0519e41c3 (patch)
tree5daa564c3a71c5e09461a1d4dcfa00ce95543ac1
parentMade a working trains script. (diff)
downloadshbot-24e26c2b661c603c07e50bb1160ce0e0519e41c3.tar.gz
shbot-24e26c2b661c603c07e50bb1160ce0e0519e41c3.tar.bz2
shbot-24e26c2b661c603c07e50bb1160ce0e0519e41c3.zip
Fixed the trains script to handle canceled trains and wrote the help command.
-rwxr-xr-xshbrain.sh2
-rwxr-xr-xshhelp.sh14
-rwxr-xr-xshtrains.sh4
3 files changed, 19 insertions, 1 deletions
diff --git a/shbrain.sh b/shbrain.sh
index 6dd968a..74fc135 100755
--- a/shbrain.sh
+++ b/shbrain.sh
@@ -15,7 +15,7 @@ do
if [ "$CMD" = "trains" ]; then
./shtrains.sh ${ARGS[*]}
elif [ "$CMD" = "help" ]; then
- echo "Help"
+ ./shhelp.sh $ARGS
else
echo "Use \"shcmd help\" to list available commands."
fi
diff --git a/shhelp.sh b/shhelp.sh
new file mode 100755
index 0000000..27d1b8f
--- /dev/null
+++ b/shhelp.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -ex
+
+case "$1" in
+ "help") echo "help <TOPIC> : Prints help about TOPIC."
+ ;;
+ "trains") echo "trains [STATION] : Prints the next trains that will stop at Courbevoie's station."
+ echo " When provided, only results that concerns STATION are advertised."
+ ;;
+ *) echo "The following commands are available : help trains"
+ ;;
+esac
+
+exit 0
+
diff --git a/shtrains.sh b/shtrains.sh
index 0d9739a..2f1936f 100755
--- a/shtrains.sh
+++ b/shtrains.sh
@@ -9,6 +9,10 @@ do
read STATION || break
read UGUU || break
[[ $PATTERN =~ \ *[A-Z]{4}\ *(.*) ]] && PATTERN=${BASH_REMATCH[1]}
+ if [[ $UGUU =~ Supprime ]]; then
+ read UGUU || break
+ continue
+ fi
if [ -n "$*" ]; then
[[ $STATION =~ $@ ]] && echo "$PATTERN $STATION"
else