I am mostly active on LinkedIn as kdabir
You can find me on Twitter (x) as @kdabir
Here is my humble Website
✅ checks presence of various command line tools and their versions on the path
License: MIT License
Just change Makefile
to install /usr/share/zsh/site-functions/_has
:
#compdef has
_arguments -s -S \
-q'[Silent mode]' \
{-h,--help}'[Display this help text and quit]' \
{-V,--version}'[Show version number and quit]' \
'*: :{_command_names -e}'
❯ has -<TAB>
external command
option
-h Display this help text and quit
--help Display this help text and quit
-q Silent mode
--version Show version number and quit
-V Show version number and quit
❯ has -q <TAB>
external command
7za A file archiver with highest compression ratio
7z A file archiver with highest compression ratio
7zr A file archiver with highest compression ratio
a2ping convert between PS, EPS and PDF and other page description formats
a52dec decode ATSC A/52 audio streams
...
TIA.
Let alone new contributors, even for myself when looking at the project after an year or so, it is very difficult to understand what the specific section of the script does.
Check for both and tally score on whether either exist?
I personally prefer rbenv 😁
https://github.com/sstephenson/rbenv
Thank you for merging #43 which gets us closer to testing every package has supports. I'll aim to submit pull requests that get us even closer to 100% in the future.
The Github Actions tests are currently using containers built from my fork of has, but it would be better if we built the containers using this official fork https://github.com/kdabir/has . That way future changes to the official dockerfiles would update the containers we use for testing.
If that sounds okay to you then could you please
testing-has
repositoryhas/.github/workflows/main.yml
Line 25 in 4ccd017
has/.github/workflows/main.yml
Line 44 in 4ccd017
If it helps: I've added you as a collaborator for my repository on https://hub.docker.com
❯ has python > a.txt && cat -A a.txt
^[[1m^[[32mM-bM-^\M-^S^[[m^O python ^[[1m^[[33m3.9.6^[[m^O$
why not let has detect stdout? if the output is a stdout, let has output with color, if the output is a file, let has output without color.
A simple solution is
# stdout is /dev/fd/1
[ -t 1 ] && color=1 || color=0
Moreover, like a option named --color={always, auto, never}
, default is auto will be better. many program like fd, rg, exa use --color
to control if the program output with color.
thanks.
Since this is achievable by following command, I don't really see the need to incorporate a flag in has
to hide versions. let's keep has
as cli-flags-free as possible.
$ has java node | cut -d' ' -f1,2
✔ java
✔ node
support -q
of something similar to disable output for command line. This can be useful in scripts using has
only for the exit status code.
Just filing this issue to let everyone know about the rename.
has $(for i in {1..256}; do echo go; done)
echo $?
This will appear to indicate success regardless of whether the system has go or not, because the real exit code of 256 is truncated (only the least significant eight bits are used).
Can consider something like apt-get
, brew
, npm
etc.
Running has
over the Internet i.e with a curl
command like the following:
curl -sL https://git.io/_has | bash -s nvim
... throws the following error:
✗ nvim not understood
I would like to make it clear, nvim
is a valid command I invoke Neovim with & running nvim --version
returns the following output:
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by linuxbrew@a1e553b903c7
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/linuxbrew/.linuxbrew/Cellar/neovim/0.6.1/share/nvim"
Run :checkhealth for more info
So, how do I check if Neovim has been installed or not with has
?
Projects can check-in their dependencies in .hasrc
or Hasfile
. Users can keep a.hasrc
in their home directory. Has should check current dir for this file or home dir.
Commands passed from CLI should be additive to the ones in this files.
``console`
$ gpg --version
gpg (GnuPG) 2.2.4
This is an umbrella issue to support more tools from various languages ecosystems like python, clojure, scala, php and others.
Following commands need to be supported. More can be added/suggested:
need to investigate if colors work across various terminals. current check is not working on OSX.
can try tput
, see here: http://unix.stackexchange.com/questions/9957/how-to-check-if-bash-can-print-colors
The script doesn't detect the presence of the node version manager script which can be used to handle having multiple node version installed. When no version is selected by default the node command is not available but that shouldn't lower the dev quotient
( you probably want to detect rvm too :D )
... for better effect! 🌈
... for obvious reasons! 😜
So that we can see how recent version of a command is installed.
Add -h and -V options
Basic getopts
version:
#-----------------------------------------------------------------------
# Handle command line arguments
#-----------------------------------------------------------------------
while getopts ":hV" opt
do
# shellcheck disable=SC2214
case "${opt}" in
h|help ) _usage; exit 0 ;;
V|version ) _version; exit 0 ;;
\? ) printf '\nInvalid option: %s\n\n' "${OPTARG}"
_usage; exit 2 ;;
esac # --- end of case ---
done
shift $(( OPTIND-1 ))
While implementing some new tools (php5
on alpine in this case), I have found that SIGPIPE
(exit code 141) is being returned. The version is correctly captured, it's just that the head
command truncates the output.
bash-4.3# bash -x ./has php5
# Removed some output here for brevity
+ __dynamic_detect php5 --version
+ cmd=php5
+ params=--version
++ eval php5 --version '2>&1'
++ +++ egrep php5 -o --version'([[:digit:]]+\.?){2,3}'
++ head -1
+ version=5.6.31
+ status=141
+ '[' 141 -eq -1 ']'
+ '[' 141 -eq 127 ']'
+ '[' 141 -eq 0 ']'
+ echo ✔ php5
✔ php5
+ OK=1
+ exit 0
I think we should output the version and treat 141 as a success. I'll put a pull request in to implement this.
Needs to be case insenstive ([Yy]
)
or just an existence check [[ -v HAS_ALLOW_UNSAFE ]]
Hi, I created Awesome package manager and I can install has
using it.
After installing the Awesome:
awesome -i kdabir/has
If you can put it in your README, it will be awesome.
Shin
``console`
$ ssh -V
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
$ openssl version
OpenSSL 1.1.1b 26 Feb 2019
no idea how yet, but sbt gets stuck sometimes (may be it was trying to download the internet).
Coupled with a single top level dq
executable, this should allow us to just drop/checkout the code into $HOME/bin
or add it to PATH
and have access to all the dq
niceness.
Awesome tool! I once wrote a similar tool, for quickly gathering disparate and differently syntaxed program information, specs:
https://github.com/mcandre/specs
Feel free to steal more commands for gathering versions into has
, I'd love to see has be able to handle Web browser versions, OS versions, and more!
https://github.com/pypa/setuptools_scm will generate a version like 0.1.dev1+ge42c9a0.d20221212
, however has
will recognize it as 0.1.
. Is it a bug?
It feels like has
should handle itself, eh ;)
$ has has
✘ has not understood
And even it was hard coded to do so, it parses its own version incorrectly:
$ HAS_ALLOW_UNSAFE=y has has
✔ has 22
This is using:
$ has
has v1.1.0
USAGE: has <command-names>..
EXAMPLE: has git curl node
First time here. Thanks for an interesting tool. In the best of the best world, all software tools should have versions and there should be a standard way of querying it.
The uninstall
target in Makefile
does not respect DESTDIR
/PREFIX
env vars and hardcodes to /usr/local/bin/
If we change the current regex, we are not sure if existing commands' version can still be extracted. we can't run all commands in CI because they might not be present on CI servers in the first place.
To solve this, the code needs to be organized such that the version extraction is decoupled from the command execution part.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.