Files
would-reformat/rustfmt.sh
2023-12-07 09:53:21 -06:00

51 lines
638 B
Bash
Executable File

#!/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