Bake in support for rustfmt

This commit is contained in:
Michael Wolf
2023-12-07 09:53:21 -06:00
parent 5c987ae777
commit 897a91b350
2 changed files with 54 additions and 0 deletions

50
rustfmt.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$DIR/_reformat-common.bash"
log "in rustfmt.sh"
set -e
file="$1"
log what
pushd "$(dirname "$file")" 2>&1
if [[ "$WOULD_REFORMAT" = "would_reformat" ]]; then
log beavis
set +e
out=$(rustfmt --check "$file" 2>&1 >/dev/null)
retval="$?"
set -e
log got back retval $retval
exit "$retval"
fi
if [[ "$WOULD_REFORMAT" = "do_reformat" ]]; then
log in do reformat mode
out=$(rustfmt "$file" 2>&1 >/dev/null)
retval="$?"
echo "$out"
log $out
exit "$retval"
fi
log are we here now
exit 255