1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-12-22 23:24:13 +01:00
rustlings/install.sh
2019-03-06 20:16:31 +01:00

52 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
echo "Let's get you set up with Rustlings!"
echo "Checking requirements..."
if [ -x "$(git)" ]
then
echo "WARNING: Git does not seem to be installed."
echo "Please download Git using your package manager or over https://git-scm.com/!"
exit 1
else
echo "SUCCESS: Git is installed"
fi
if [ -x "$(rustc)" ]
then
echo "WARNING: Rust does not seem to be installed."
echo "Please download Rust using https://rustup.rs!"
exit 1
else
echo "SUCCESS: Rust is installed"
fi
if [ -x "$(cargo)" ]
then
echo "WARNING: Cargo does not seem to be installed."
echo "Please download Rust and Cargo using https://rustup.rs!"
exit 1
else
echo "SUCCESS: Cargo is installed"
fi
Path=${1:-rustlings/}
echo "Cloning Rustlings at $Path..."
git clone -q https://github.com/rust-lang/rustlings $Path
Version=$(curl -s https://api.github.com/repos/rust-lang/rustlings/releases/latest | python -c "import json,sys;obj=json.load(sys.stdin);print(obj['tag_name']);")
echo "Checking out version $Version..."
cd $Path
git checkout -q tags/$Version
echo "Installing the 'rustlings' executable..."
cargo install --force --path .
if [ -x "$(rustlings)" ]
then
echo "WARNING: Please check that you have '~/.cargo/bin' in your PATH environment variable!"
fi
echo "All done! Run 'rustlings' to get started."