2
1
mirror of https://github.com/kdabir/has.git synced 2024-11-10 21:26:50 +01:00

More version goodies. ability to disable version display.

This commit is contained in:
Kunal Dabir 2015-02-13 10:13:23 +05:30
parent 45616090c8
commit 7eccca0a44
13 changed files with 81 additions and 27 deletions

View File

@ -25,7 +25,7 @@ def build *args
.sort { |x, y| File.basename(x) <=> File.basename(y) } # sort alphabetically
.collect { |file| File.read(file) }.join("\n") # concat
[File.read("include/setup.sh"), content, File.read("include/report.sh")].join("\n")
[File.read("include/setup.sh"), content, File.read("include/report.sh")].join("\n\n")
end
puts build *ARGV unless ARGV.empty?

View File

@ -4,20 +4,30 @@ KO=0
PASS='✔'
FAIL='✘'
# by default show installed versions
NO_VERSION=1
if [[ "$1" == "--no-version" ]]; then
NO_VERSION=0
fi
if [[ $TERM == xterm-*color ]]; then
PASS="\E[32m$PASS\E[0m"
FAIL="\E[31m$FAIL\E[0m"
fi
# $1 command name
# $2 0 ok anything else
# $3 version
# $2 0 OK, anything else KO
# $3 optional version string, should send in quotes
_dq_report () {
if [ "$2" -eq 0 ]; then
echo -e "$PASS $1 $3"
if [ "$NO_VERSION" -eq 0 ]; then
printf "$PASS $1\n"
else
printf "$PASS %-30s %s\n" $1 $3
fi
OK=$(($OK+1))
else
echo -e "$FAIL $1"
printf "$FAIL $1\n"
KO=$(($KO+1))
fi
}

View File

@ -1,2 +1,6 @@
git --version > /dev/null 2>&1
_dq_report 'git' $?
command_name="git"
output=$(git --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
node --version > /dev/null 2>&1
_dq_report 'node' $?
command_name="node"
output=$(node --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
mongo --version > /dev/null 2>&1
_dq_report 'mongo client' $?
command_name="mongo-client"
output=$(mongo --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*" | head -1)
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
mongod --version > /dev/null 2>&1
_dq_report 'mongo server' $?
command_name="mongodb"
output=$(mongod --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*" | head -1)
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
bower --version > /dev/null 2>&1
_dq_report 'bower' $?
command_name="bower"
output=$(bower --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
coffee --version > /dev/null 2>&1
_dq_report 'coffee' $?
command_name="coffee"
output=$(coffee --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
grunt --version > /dev/null 2>&1
_dq_report 'grunt' $?
command_name="grunt"
output=$(grunt --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
npm --version > /dev/null 2>&1
_dq_report 'npm' $?
command_name="npm"
output=$(npm --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
sass --version > /dev/null 2>&1
_dq_report 'sass' $?
command_name="sass"
output=$(sass --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
yo --version > /dev/null 2>&1
_dq_report 'yeoman' $?
command_name="yeoman"
output=$(yo --version)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*.\d*")
_dq_report "$command_name" $status "$version"

View File

@ -1,2 +1,6 @@
gradle -v > /dev/null 2>&1
_dq_report 'gradle' $?
command_name="gradle"
output=$(gradle -v 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*" | head -1)
_dq_report "$command_name" $status "$version"