diff options
| author | lyn <819880950@qq.com> | 2019-03-06 20:16:31 +0100 |
|---|---|---|
| committer | lyn <819880950@qq.com> | 2019-03-06 20:16:31 +0100 |
| commit | 9a14d72f08afe459f4b2407c50ed67c06a626894 (patch) | |
| tree | 612c8eae119529e61d481925cd1836d76914ae8c | |
| parent | 244a0816ac79bd739f3c87067ddf0d29ce1e434b (diff) | |
add a basic install script
| -rwxr-xr-x | install.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..b286025 --- /dev/null +++ b/install.sh @@ -0,0 +1,51 @@ +#!/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." + |
