Skip to content

Instantly share code, notes, and snippets.

@senorsmile
Created April 3, 2021 22:38
Show Gist options
  • Select an option

  • Save senorsmile/d83ec34cecbe68ff2c93a59282cb79bf to your computer and use it in GitHub Desktop.

Select an option

Save senorsmile/d83ec34cecbe68ff2c93a59282cb79bf to your computer and use it in GitHub Desktop.
Rust cargo runner script
#!/usr/bin/env bash
set -euo pipefail
#----------
# vars
#----------
debug=1
clippy=1
#----------
# diesel
#----------
diesel() {
[[ $debug == 1 ]] && echo "****** INSTALL DIESEL"
cargo install diesel_cli --no-default-features --features postgres || {
echo "ERROR: Do you need to install the postgresql client?"
}
}
#----------
# clippy
#----------
clippy() {
[[ $clippy == 1 ]] && {
[[ $debug == 1 ]] && echo "****** RUN CLIPPY"
clippy_opts=(
-D "clippy::shadow_unrelated"
-D "clippy::shadow_same"
-D "clippy::shadow_reuse"
-D "clippy::pedantic"
-W "clippy::cargo"
)
# issue: https://github.com/rust-lang/rust-clippy/issues/4612
#find . | grep "\.rs$" | xargs touch
find -name "*.rs" -not -path "./target/*" -exec touch "{}" +
cargo clippy -- ${clippy_opts[@]}
}
}
#----------
# build and run
#----------
cargo_run() {
[[ $debug == 1 ]] && echo "****** BUILD AND RUN"
cargo run
}
main() {
diesel
clippy
cargo_run
}
time main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment