Browse Source

Merge branch 'email' of marioforzanini/lcmlog into master

Matteo Zeccoli Marazzini 2 years ago
parent
commit
0f726ba661
1 changed files with 12 additions and 2 deletions
  1. 12 2
      lcmlog

+ 12 - 2
lcmlog

@@ -76,7 +76,7 @@ method_get()
 	read DATE
 	while ! [ -z $DATE ]; do
 		if [ ${DATE:4:1} != '-' ] || [ ${DATE:7:1} != '-' ] || (( ${#DATE} != 10 )); then
-			echo "Format: yyyy-mm-dd (i.e. 9 is 09). Reinsert."	
+			echo "Format: yyyy-mm-dd (i.e. 9 is 09). Reinsert."
 			read DATE
 		else
 			break
@@ -276,7 +276,7 @@ method_post()
 		elif [ $CHAR == "p" ]; then
 			MP="pom"
 		fi
-		
+
 		DATE=$YEAR"-"$MONTH"-"$DAY"_"$MP
 	else
 		DATE=$YEAR"-"$MONTH"-"$DAY
@@ -292,12 +292,22 @@ method_post()
 		read TAGS
 	done
 
+	SEND_MAIL=""
+	read -p "Send the log via email? [default: y] " AUX
+	while [ "$AUX" != "y" ] && [ "$AUX" != "n" ] && ! [ -z "$AUX" ]; do
+		read -p "Yes (y) or no (n)? [default: y] " AUX
+	done
+	[ -z "$AUX" ] && AUX="y"
+	if [ "$AUX" = "y" ]; then
+		SEND_MAIL="MAIL"
+	fi
 
 	# Update of the pipe
 	printf "%s\n" "POST" >> $pipe
 	printf "%s\n" "${KIND}" >> $pipe
 	printf "%s\n" "${DATE}" >> $pipe
 	printf "%s\n" "${TAGS}" >> $pipe
+	[ -z "$SEND_MAIL" ] || printf "%s\n" "${SEND_MAIL}" >> $pipe
 
 
 	# Write log