dotfiles/scripts/rust

49 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2020-06-03 14:31:58 +00:00
#!/bin/sh
install_rust() {
if ! (which ~/.cargo/bin/rustup > /dev/null)
then
echo "installing rustup"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
echo "rustup ✓"
}
update_rust() {
~/.cargo/bin/rustup update > /dev/null 2>&1
rust_version=$(~/.cargo/bin/rustc --version | awk '{print $2}')
echo "latest rust: $rust_version ✓"
}
download_rust_analyzer() {
if ! (which rust-analyzer > /dev/null)
then
echo "downloading rust analyzer"
rust_analyzer_bin=/usr/local/bin/rust-analyzer
2020-08-02 14:20:25 +00:00
curl -s -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-mac -o $rust_analyzer_bin
2020-06-03 14:31:58 +00:00
chmod +x $rust_analyzer_bin
fi
echo "rust-analyzer ✓"
}
2021-04-28 12:58:14 +00:00
# cargo-edit: quickly add and remove packages
# whatfeatures: see optional features for a package
2020-08-02 14:20:25 +00:00
install_cargos() {
2021-04-10 17:15:14 +00:00
set -- \
2021-04-28 12:58:14 +00:00
'cargo-edit' \
'cargo-whatfeatures'
2021-04-10 17:15:14 +00:00
for program do
cargo install "$program"
2020-08-02 14:20:25 +00:00
done
2021-04-10 17:15:14 +00:00
echo "cargos ✓"
2020-06-03 14:31:58 +00:00
}
install_rust
update_rust
download_rust_analyzer
2020-08-02 14:20:25 +00:00
install_cargos