Bake in support for rustfmt
This commit is contained in:
@@ -147,6 +147,8 @@ function sniff_file_type() {
|
|||||||
file_type="dart"
|
file_type="dart"
|
||||||
elif [[ $ff = *.pl ]]; then
|
elif [[ $ff = *.pl ]]; then
|
||||||
file_type="perl"
|
file_type="perl"
|
||||||
|
elif [[ $ff = *.rs ]] ; then
|
||||||
|
file_type="rust"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $file_type
|
echo $file_type
|
||||||
@@ -191,6 +193,8 @@ function choose_wrapper() {
|
|||||||
out="$WF_ROOT"/./isort-and-black.sh
|
out="$WF_ROOT"/./isort-and-black.sh
|
||||||
elif [[ $file_type == "golang" ]]; then
|
elif [[ $file_type == "golang" ]]; then
|
||||||
out="$WF_ROOT"/./gofmt.sh
|
out="$WF_ROOT"/./gofmt.sh
|
||||||
|
elif [[ $file_type == "rust" ]] ; then
|
||||||
|
out="$WF_ROOT"/./rustfmt.sh
|
||||||
elif [[ $file_type == "dart" ]]; then
|
elif [[ $file_type == "dart" ]]; then
|
||||||
out="$WF_ROOT"/./dart_format.sh
|
out="$WF_ROOT"/./dart_format.sh
|
||||||
else
|
else
|
||||||
|
|||||||
50
rustfmt.sh
Executable file
50
rustfmt.sh
Executable 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
|
||||||
Reference in New Issue
Block a user