Skip to content

Instantly share code, notes, and snippets.

@lqd
Created July 5, 2018 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lqd/4a8af10389d10840d90655c109df5eac to your computer and use it in GitHub Desktop.
Save lqd/4a8af10389d10840d90655c109df5eac to your computer and use it in GitHub Desktop.
#!/bin/bash
__printusage() {
echo "Usage: $1 <crate> <version> | <crate>-<version>"
echo ""
echo "e.g. $1 conrod 0.32.0"
}
if [[ "$#" == 2 ]]; then
_crate=$1
_version=$2
elif [[ "$1" =~ .+-([0-9]+(\.)?)+$ ]]; then
_crate=${1%-*}
_version=${1##*-}
else
__printusage $0
exit 1
fi
curl -L https://crates.io/api/v1/crates/$_crate/$_version/download | tar zxf -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment