Created
April 3, 2021 22:38
-
-
Save senorsmile/d83ec34cecbe68ff2c93a59282cb79bf to your computer and use it in GitHub Desktop.
Rust cargo runner script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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