mirror of https://github.com/kdabir/has.git
minor refactoring but changes to CLI. add pnpm
- use -v instead of -V for has version - use '-' in color-<auto|always|never> instead of '_'
This commit is contained in:
parent
54c334962c
commit
abb3decba7
47
has
47
has
|
@ -7,7 +7,7 @@
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
readonly BINARY_NAME="has"
|
readonly BINARY_NAME="has"
|
||||||
readonly VERSION="v1.6.0"
|
readonly VERSION="v1.7.0"
|
||||||
|
|
||||||
## constants - symbols for success failure
|
## constants - symbols for success failure
|
||||||
if [[ ! -t 1 ]]; then
|
if [[ ! -t 1 ]]; then
|
||||||
|
@ -74,7 +74,7 @@ _version() {
|
||||||
_set_color() {
|
_set_color() {
|
||||||
local found=0;
|
local found=0;
|
||||||
for opt in "${COLOR_OPTS[@]}"; do
|
for opt in "${COLOR_OPTS[@]}"; do
|
||||||
[ "${1}" == "${COLOR_PREFIX}_${opt}" ] && COLOR="${opt}" && found=1 && break
|
[ "${1}" == "${COLOR_PREFIX}-${opt}" ] && COLOR="${opt}" && found=1 && break
|
||||||
done
|
done
|
||||||
[ ${found} -eq 1 ] || >&2 echo "Error: wrong flag ${1}"
|
[ ${found} -eq 1 ] || >&2 echo "Error: wrong flag ${1}"
|
||||||
}
|
}
|
||||||
|
@ -165,11 +165,9 @@ __detect(){
|
||||||
ag|ack|rg) __dynamic_detect--version "${command}" ;;
|
ag|ack|rg) __dynamic_detect--version "${command}" ;;
|
||||||
tree|autojump) __dynamic_detect--version "${command}" ;;
|
tree|autojump) __dynamic_detect--version "${command}" ;;
|
||||||
|
|
||||||
## Package managers
|
## OS Package managers
|
||||||
apt|apt-get|aptitude) __dynamic_detect--version "${command}" ;;
|
apt|apt-get|aptitude) __dynamic_detect--version "${command}" ;;
|
||||||
brew) __dynamic_detect--version "${command}" ;;
|
brew) __dynamic_detect--version "${command}" ;;
|
||||||
composer) __dynamic_detect-V "${command}" ;;
|
|
||||||
pip|pip3|conda) __dynamic_detect-V "${command}" ;;
|
|
||||||
|
|
||||||
## System tools
|
## System tools
|
||||||
sed|awk|grep|file|sudo) __dynamic_detect--version "${command}" ;;
|
sed|awk|grep|file|sudo) __dynamic_detect--version "${command}" ;;
|
||||||
|
@ -186,20 +184,29 @@ __detect(){
|
||||||
psql) __dynamic_detect--version "${command}" ;;
|
psql) __dynamic_detect--version "${command}" ;;
|
||||||
sqlite3) __dynamic_detect-version "${command}" ;;
|
sqlite3) __dynamic_detect-version "${command}" ;;
|
||||||
|
|
||||||
|
|
||||||
|
########### Programming languages Build tools & Package managers ###########
|
||||||
|
|
||||||
|
|
||||||
|
## Build and Compile
|
||||||
|
gcc|make|cmake|bats) __dynamic_detect--version "${command}" ;;
|
||||||
|
ninja) __dynamic_detect--version "${command}" ;;
|
||||||
|
composer) __dynamic_detect-V "${command}" ;;
|
||||||
|
pip|pip3|conda) __dynamic_detect-V "${command}" ;;
|
||||||
|
lein|gradle|mvn) __dynamic_detect--version "${command}" ;;
|
||||||
|
grunt|brunch) __dynamic_detect--version "${command}" ;;
|
||||||
|
gem|rake|bundle) __dynamic_detect--version "${command}" ;;
|
||||||
|
npm|yarn|pnpm) __dynamic_detect--version "${command}" ;;
|
||||||
|
act) __dynamic_detect--version "${command}" ;;
|
||||||
|
|
||||||
## Scripting Language / runtime
|
## Scripting Language / runtime
|
||||||
ruby|R|python|python3) __dynamic_detect--version "${command}" ;;
|
ruby|R|python|python3) __dynamic_detect--version "${command}" ;;
|
||||||
perl|perl6|php|php5) __dynamic_detect--version "${command}" ;;
|
perl|perl6|php|php5) __dynamic_detect--version "${command}" ;;
|
||||||
groovy|node) __dynamic_detect--version "${command}" ;;
|
groovy|node) __dynamic_detect--version "${command}" ;;
|
||||||
|
|
||||||
## Compile
|
# JVM tools that need -version flag
|
||||||
gcc|make|cmake|bats) __dynamic_detect--version "${command}" ;;
|
ant) __dynamic_detect-version "${command}" ;;
|
||||||
ninja) __dynamic_detect--version "${command}" ;;
|
java|javac|scala|kotlin) __dynamic_detect-version "${command}" ;;
|
||||||
|
|
||||||
## Build tools
|
|
||||||
lein|gradle|mvn) __dynamic_detect--version "${command}" ;;
|
|
||||||
grunt|brunch) __dynamic_detect--version "${command}" ;;
|
|
||||||
gem|rake|bundle) __dynamic_detect--version "${command}" ;;
|
|
||||||
npm|yarn) __dynamic_detect--version "${command}" ;;
|
|
||||||
|
|
||||||
## Rust
|
## Rust
|
||||||
rustc|cargo) __dynamic_detect--version "${command}" ;;
|
rustc|cargo) __dynamic_detect--version "${command}" ;;
|
||||||
|
@ -211,7 +218,8 @@ __detect(){
|
||||||
netlifyctl) __dynamic_detect-arg_version "${command}" ;;
|
netlifyctl) __dynamic_detect-arg_version "${command}" ;;
|
||||||
|
|
||||||
## GPG Tools
|
## GPG Tools
|
||||||
gpg|gpgconf|gpg-agent|gpg-connect-agent) __dynamic_detect--version "${command}" ;;
|
gpg|gpgconf|gpg-agent) __dynamic_detect--version "${command}" ;;
|
||||||
|
gpg-connect-agent) __dynamic_detect--version "${command}" ;;
|
||||||
gpgsm) __dynamic_detect--version "${command}" ;;
|
gpgsm) __dynamic_detect--version "${command}" ;;
|
||||||
|
|
||||||
## Hashicorp Tools
|
## Hashicorp Tools
|
||||||
|
@ -228,9 +236,6 @@ __detect(){
|
||||||
# commands that need -V flag
|
# commands that need -V flag
|
||||||
ab) __dynamic_detect-V "${command}" ;;
|
ab) __dynamic_detect-V "${command}" ;;
|
||||||
|
|
||||||
# commands that need -version flag
|
|
||||||
ant) __dynamic_detect-version "${command}" ;;
|
|
||||||
java|javac|scala|kotlin) __dynamic_detect-version "${command}" ;;
|
|
||||||
|
|
||||||
# commands that need version arg
|
# commands that need version arg
|
||||||
go|hugo) __dynamic_detect-arg_version "${command}" ;;
|
go|hugo) __dynamic_detect-arg_version "${command}" ;;
|
||||||
|
@ -282,7 +287,7 @@ __detect(){
|
||||||
;;
|
;;
|
||||||
|
|
||||||
has)
|
has)
|
||||||
version=$( has -V 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
|
version=$( has -v 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
|
||||||
status=$?
|
status=$?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -327,7 +332,7 @@ __detect(){
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
OUTPUT=/dev/stdout
|
OUTPUT=/dev/stdout
|
||||||
|
|
||||||
while getopts ":qhV-" OPTION; do
|
while getopts ":qhv-" OPTION; do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
q)
|
q)
|
||||||
QUIET="true"
|
QUIET="true"
|
||||||
|
@ -337,7 +342,7 @@ while getopts ":qhV-" OPTION; do
|
||||||
_usage
|
_usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
V)
|
v)
|
||||||
_version
|
_version
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue