Last active
July 21, 2018 16:57
-
-
Save djfdyuruiry/9e903c9b0dbc87eaeda5ae4faacc720c to your computer and use it in GitHub Desktop.
Maven Central Search Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
if [ "$#" -lt 1 ] || [ -z "$1" ]; then | |
>&2 echo "Usage: $0 searchTerm [searchResultLimit] # default searchResultLimit is 5" | |
exit 1 | |
fi | |
if [ -z "$(command -v python)" ]; then | |
>&2 echo "$0 requires python to be installed and in the current PATH" | |
exit 1 | |
fi | |
queryMavenCentral() { | |
echo "--" | |
wget "http://search.maven.org/solrsearch/select?q=$1&rows=${2:-5}&wt=json" -q --output-document - \ | |
| python -m json.tool \ | |
| grep -A 1 '"id"' || echo "No results found" | |
echo "--" | |
} | |
queryMavenCentral "$1" $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment