From 11984e8d8160201c3cd02d44a151fc38a5e93fbf Mon Sep 17 00:00:00 2001 From: Saager Mhatre Date: Mon, 12 May 2014 15:44:41 +0530 Subject: [PATCH] Update reporter; colourize output Closes #6 --- bin/all/dq.sh | 24 ++++++++++++++++-------- bin/clojure_dev/dq.sh | 24 ++++++++++++++++-------- bin/core/dq.sh | 24 ++++++++++++++++-------- bin/db/dq.sh | 24 ++++++++++++++++-------- bin/frontend_dev/dq.sh | 24 ++++++++++++++++-------- bin/groovy_dev/dq.sh | 24 ++++++++++++++++-------- bin/java_dev/dq.sh | 24 ++++++++++++++++-------- bin/ruby_dev/dq.sh | 24 ++++++++++++++++-------- bin/scala_dev/dq.sh | 24 ++++++++++++++++-------- bin/shell/dq.sh | 24 ++++++++++++++++-------- include/report.sh | 2 +- include/setup.sh | 22 +++++++++++++++------- 12 files changed, 176 insertions(+), 88 deletions(-) diff --git a/bin/all/dq.sh b/bin/all/dq.sh index 40d6701..033d457 100755 --- a/bin/all/dq.sh +++ b/bin/all/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } ack --version > /dev/null 2>&1 @@ -127,6 +135,6 @@ _dq_report 'yeoman' $? zsh --version > /dev/null 2>&1 _dq_report 'zsh' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/clojure_dev/dq.sh b/bin/clojure_dev/dq.sh index fc2d5db..0d198be 100755 --- a/bin/clojure_dev/dq.sh +++ b/bin/clojure_dev/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } ## surprisingly no option for version that i could find of @@ -21,6 +29,6 @@ _dq_report 'java' $? lein -v > /dev/null 2>&1 _dq_report 'leiningen' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/core/dq.sh b/bin/core/dq.sh index 32927b3..4cb03c1 100755 --- a/bin/core/dq.sh +++ b/bin/core/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } curl --version > /dev/null 2>&1 @@ -33,6 +41,6 @@ _dq_report 'ruby' $? vi --version > /dev/null 2>&1 _dq_report 'vi' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/db/dq.sh b/bin/db/dq.sh index 87132fe..ad4043a 100755 --- a/bin/db/dq.sh +++ b/bin/db/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } mongo --version > /dev/null 2>&1 @@ -23,6 +31,6 @@ _dq_report 'mysql client' $? psql --version > /dev/null 2>&1 _dq_report 'postgres client' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/frontend_dev/dq.sh b/bin/frontend_dev/dq.sh index f689d82..3a19c5c 100755 --- a/bin/frontend_dev/dq.sh +++ b/bin/frontend_dev/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } bower --version > /dev/null 2>&1 @@ -46,6 +54,6 @@ _dq_report 'vi' $? yo --version > /dev/null 2>&1 _dq_report 'yeoman' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/groovy_dev/dq.sh b/bin/groovy_dev/dq.sh index 7b90d25..7d3d140 100755 --- a/bin/groovy_dev/dq.sh +++ b/bin/groovy_dev/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } gradle -v > /dev/null 2>&1 @@ -22,6 +30,6 @@ _dq_report 'java' $? lazybones --version > /dev/null 2>&1 _dq_report 'lazybones' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/java_dev/dq.sh b/bin/java_dev/dq.sh index a6ea2bc..0bc80d6 100755 --- a/bin/java_dev/dq.sh +++ b/bin/java_dev/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } ant -version > /dev/null 2>&1 @@ -25,6 +33,6 @@ _dq_report 'javac' $? mvn -v > /dev/null 2>&1 _dq_report 'maven' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/ruby_dev/dq.sh b/bin/ruby_dev/dq.sh index 7e4e762..18e9804 100755 --- a/bin/ruby_dev/dq.sh +++ b/bin/ruby_dev/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } bundle -v > /dev/null 2>&1 @@ -26,6 +34,6 @@ _dq_report 'ruby' $? rvm -v > /dev/null 2>&1 _dq_report 'rvm' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/scala_dev/dq.sh b/bin/scala_dev/dq.sh index f263f92..8954289 100755 --- a/bin/scala_dev/dq.sh +++ b/bin/scala_dev/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } java -version > /dev/null 2>&1 @@ -32,6 +40,6 @@ _dq_report 'scala' $STATUS scalac -version > /dev/null 2>&1 _dq_report 'scalac' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/bin/shell/dq.sh b/bin/shell/dq.sh index 6d666b3..08f40d1 100755 --- a/bin/shell/dq.sh +++ b/bin/shell/dq.sh @@ -1,14 +1,22 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi } ack --version > /dev/null 2>&1 @@ -26,6 +34,6 @@ _dq_report 'wget' $? zsh --version > /dev/null 2>&1 _dq_report 'zsh' $? -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/include/report.sh b/include/report.sh index 70f6f1b..7eb2981 100644 --- a/include/report.sh +++ b/include/report.sh @@ -1,3 +1,3 @@ -echo Your dq is $OK / $(($OK+$KO)) +echo; echo Your dq is $OK / $(($OK+$KO)) exit $KO diff --git a/include/setup.sh b/include/setup.sh index 76ce77d..2a45973 100644 --- a/include/setup.sh +++ b/include/setup.sh @@ -1,12 +1,20 @@ OK=0 KO=0 +PASS='✔' +FAIL='✘' + +if [[ $TERM == xterm-*color ]]; then + PASS="\E[32m$PASS\E[0m" + FAIL="\E[31m$FAIL\E[0m" +fi + _dq_report () { - if [ "$2" -eq 0 ]; then - echo "✔ $1" - OK=$(($OK+1)) - else - echo "✘ $1" - KO=$(($KO+1)) - fi + if [ "$2" -eq 0 ]; then + echo -e "$PASS $1" + OK=$(($OK+1)) + else + echo -e "$FAIL $1" + KO=$(($KO+1)) + fi }