From 1257f37b55dc74ab5b3a9457b3c8a4f4fc22ee62 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Fri, 30 Apr 2021 22:33:07 +0500 Subject: [PATCH] added clear and exit as valid input --- contactsmenu.sh | 40 ++++++++++++++++++++++++---------------- mainmenu.sh | 15 ++++++++++----- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/contactsmenu.sh b/contactsmenu.sh index 3cfbf63..21794e0 100644 --- a/contactsmenu.sh +++ b/contactsmenu.sh @@ -3,32 +3,40 @@ echo "Contacts" echo "" echo "1 - List Contacts" echo "2 - Add Contact" -echo "3 - Delete Conact" +echo "3 - Delete Contact" echo "4 - Go back" -echo "5 - Exit" echo "" printf 'Please Input: ' -read -r CONTATCS +read -r CONTACTS -if [ "$CONTATCS" = "1" ] - then +if [ "$CONTACTS" = "1" ] +then source listcontacts.sh -elif [ "$CONTATCS" = "2" ] - then +elif [ "$CONTACTS" = "2" ] +then source addcontact-menu.sh -elif [ "$CONTATCS" = "3" ] - then +elif [ "$CONTACTS" = "3" ] +then source deletecontact.sh -elif [ "$CONTATCS" = "4" ] - then +elif [ "$CONTACTS" = "4" ] +then source mainmenu.sh -elif [ "$CONTATCS" = "5" ] - then - rm $COOKIE +elif [ "$CONTACTS" = "back" ] +then + sleep 0.2 + source mainmenu.sh +elif [ "$CONTACTS" = "clear" ] +then + sleep 0.2 + clear + source contactsmenu.sh +elif [ "$CONTACTS" = "exit" ] +then echo "Cleaning up.." + rm $COOKIE + sleep 0.2 exit else - - echo "${red}There was an error${reset}" 1>&2 + echo ${red}Invalid input:${yellow} $CONTACTS ${reset} 1>&2 source contactsmenu.sh fi diff --git a/mainmenu.sh b/mainmenu.sh index 8e19b9e..ec3f533 100644 --- a/mainmenu.sh +++ b/mainmenu.sh @@ -6,7 +6,6 @@ echo "3 - Contacts" echo "4 - Activities" echo "5 - Services" echo "6 - Settings" -echo "7 - Exit" echo "" printf 'Please Input: ' read -r MENU @@ -44,12 +43,18 @@ elif [ "$MENU" = "6" ] sleep 2 source mainmenu.sh source settingsmenu.sh -elif [ "$MENU" = "7" ] +elif [ "$MENU" = "clear" ] then + clear + sleep 0.2 + source mainmenu.sh +elif [ "$MENU" = "exit" ] + then + echo "cleaning up..." rm $COOKIE + sleep 0.2 exit else - echo "${red}There was an error${reset}" 1>&2 - - source mainmenu.sh + echo ${red}Invalid input:${yellow} $MENU ${reset} 1>&2 + source mainmenu.sh fi