Unit/amount complete.

This commit is contained in:
2021-04-29 15:47:47 +02:00
parent 5b81de7484
commit 34eb2ba9bf
3 changed files with 255 additions and 42 deletions

View File

@ -1,12 +1,32 @@
#!/bin/bash
SHOPPINGITEM=""
AMOUNT=""
UNIT=""
SITEID=""
PARAMS=""
SESSIONID=""
while (( "$#" )); do
case "$1" in
--shoppingAmount)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
AMOUNT=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--shoppingUnit)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
UNIT=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--shoppingProduct)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
SHOPPINGITEM=$2
@ -53,7 +73,21 @@ then
echo "Was soll ich auf die Liste setzen?"
exit 1
else
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingProduct $SHOPPINGITEM
lengthAmount=${#AMOUNT}
lengthUnit=${#UNIT}
if [ $lengthAmount -gt 0 ]
then
if [ $lengthUnit -gt 0 ]
then
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingAmount $AMOUNT --shoppingUnit $UNIT --shoppingProduct $SHOPPINGITEM
else
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingAmount $AMOUNT --shoppingProduct $SHOPPINGITEM
fi
else
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingProduct $SHOPPINGITEM
fi
if [ "$?" -eq "0" ]
then
exit 0

View File

@ -1,12 +1,32 @@
#!/bin/bash
SHOPPINGITEM=""
AMOUNT=""
UNIT=""
SITEID=""
PARAMS=""
SESSIONID=""
while (( "$#" )); do
case "$1" in
--shoppingAmount)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
AMOUNT=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--shoppingUnit)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
UNIT=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--shoppingProduct)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
SHOPPINGITEM=$2
@ -53,11 +73,25 @@ then
echo "Was soll ich von der Liste streichen?"
exit 1
else
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingProduct $SHOPPINGITEM
if [ "$?" -eq "0" ]
then
exit 0
else
exit 1
fi
lengthAmount=${#AMOUNT}
lengthUnit=${#UNIT}
if [ $lengthAmount -gt 0 ]
then
if [ $lengthUnit -gt 0 ]
then
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingAmount $AMOUNT --shoppingUnit $UNIT --shoppingProduct $SHOPPINGITEM
else
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingAmount $AMOUNT --shoppingProduct $SHOPPINGITEM
fi
else
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingProduct $SHOPPINGITEM
fi
if [ "$?" -eq "0" ]
then
exit 0
else
exit 1
fi
fi