Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
Last active July 21, 2018 16:57
Show Gist options
  • Save djfdyuruiry/9e903c9b0dbc87eaeda5ae4faacc720c to your computer and use it in GitHub Desktop.
Save djfdyuruiry/9e903c9b0dbc87eaeda5ae4faacc720c to your computer and use it in GitHub Desktop.
Maven Central Search Script
#/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