Fixed the trains script to handle canceled trains and wrote the help command.
This commit is contained in:
parent
d44fb2f6ba
commit
24e26c2b66
3 changed files with 19 additions and 1 deletions
|
@ -15,7 +15,7 @@ do
|
||||||
if [ "$CMD" = "trains" ]; then
|
if [ "$CMD" = "trains" ]; then
|
||||||
./shtrains.sh ${ARGS[*]}
|
./shtrains.sh ${ARGS[*]}
|
||||||
elif [ "$CMD" = "help" ]; then
|
elif [ "$CMD" = "help" ]; then
|
||||||
echo "Help"
|
./shhelp.sh $ARGS
|
||||||
else
|
else
|
||||||
echo "Use \"shcmd help\" to list available commands."
|
echo "Use \"shcmd help\" to list available commands."
|
||||||
fi
|
fi
|
||||||
|
|
14
shhelp.sh
Executable file
14
shhelp.sh
Executable file
|
@ -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
|
||||||
|
|
|
@ -9,6 +9,10 @@ do
|
||||||
read STATION || break
|
read STATION || break
|
||||||
read UGUU || break
|
read UGUU || break
|
||||||
[[ $PATTERN =~ \ *[A-Z]{4}\ *(.*) ]] && PATTERN=${BASH_REMATCH[1]}
|
[[ $PATTERN =~ \ *[A-Z]{4}\ *(.*) ]] && PATTERN=${BASH_REMATCH[1]}
|
||||||
|
if [[ $UGUU =~ Supprime ]]; then
|
||||||
|
read UGUU || break
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if [ -n "$*" ]; then
|
if [ -n "$*" ]; then
|
||||||
[[ $STATION =~ $@ ]] && echo "$PATTERN $STATION"
|
[[ $STATION =~ $@ ]] && echo "$PATTERN $STATION"
|
||||||
else
|
else
|
||||||
|
|
Reference in a new issue