2
1
mirror of https://github.com/kdabir/has.git synced 2024-09-18 17:01:29 +02: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 .sort { |x, y| File.basename(x) <=> File.basename(y) } # sort alphabetically
.collect { |file| File.read(file) }.join("\n") # concat .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 end
puts build *ARGV unless ARGV.empty? puts build *ARGV unless ARGV.empty?

View File

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

View File

@ -1,2 +1,6 @@
git --version > /dev/null 2>&1 command_name="git"
_dq_report '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 command_name="node"
_dq_report '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 command_name="mongo-client"
_dq_report '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 command_name="mongodb"
_dq_report 'mongo server' $? 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 command_name="bower"
_dq_report '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 command_name="coffee"
_dq_report '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 command_name="grunt"
_dq_report '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 command_name="npm"
_dq_report '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 command_name="sass"
_dq_report '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 command_name="yeoman"
_dq_report '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 command_name="gradle"
_dq_report 'gradle' $? output=$(gradle -v 2>&1)
status=$?
version=$(echo "$output" | grep -o "\d*\.\d*" | head -1)
_dq_report "$command_name" $status "$version"