From 1a55afa5fd1bdd4869c75b952f8abf28095b49a6 Mon Sep 17 00:00:00 2001 From: Antonio David Villegas Yeguas Date: Thu, 1 Oct 2020 17:59:28 +0200 Subject: [PATCH] Add confirmation message Solve #14 --- g | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/g b/g index 7acab2a..6d75ab0 100755 --- a/g +++ b/g @@ -11,26 +11,36 @@ do_add() { for file in "$PARAMS" do - case $file in - *.js ) - printf "$(tput setaf 1)" - node --check $file && git $CMD $file - printf "$(tput sgr0)" - ;; - *.go ) - printf "$(tput setaf 1)" - gofmt -e $file > /dev/null && git $CMD $file - printf "$(tput sgr0)" - ;; - *.php ) - printf "$(tput setaf 1)" - php -l $file && git $CMD $file - printf "$(tput sgr0)" - ;; - * ) - echo "$(tput setaf 3)Warning, file extension is Unchecked, please add a checker to g (https://github.com/dataf3l/g), with your help, we can have a world where nothing is Unchecked.$(tput sgr0)" - git $CMD $file - esac + printf "Are you sure you want to add $file ?[yes/no]" + read answer + + while [ "$answer" != "yes" ] && [ "$answer" != "no" ]; do + printf "You need to answer 'yes' or 'no': " + read answer + done + + if [ "$answer" = "yes" ]; then + case $file in + *.js ) + printf "$(tput setaf 1)" + node --check $file && git $CMD $file + printf "$(tput sgr0)" + ;; + *.go ) + printf "$(tput setaf 1)" + gofmt -e $file > /dev/null && git $CMD $file + printf "$(tput sgr0)" + ;; + *.php ) + printf "$(tput setaf 1)" + php -l $file && git $CMD $file + printf "$(tput sgr0)" + ;; + * ) + echo "$(tput setaf 3)Warning, file extension is Unchecked, please add a checker to g (https://github.com/dataf3l/g), with your help, we can have a world where nothing is Unchecked.$(tput sgr0)" + git $CMD $file + esac + fi done } main () {