summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlyn <819880950@qq.com>2019-03-06 20:16:31 +0100
committerlyn <819880950@qq.com>2019-03-06 20:16:31 +0100
commit9a14d72f08afe459f4b2407c50ed67c06a626894 (patch)
tree612c8eae119529e61d481925cd1836d76914ae8c
parent244a0816ac79bd739f3c87067ddf0d29ce1e434b (diff)
add a basic install script
-rwxr-xr-xinstall.sh51
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."
+