-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathfmt
More file actions
executable file
·38 lines (37 loc) · 802 Bytes
/
fmt
File metadata and controls
executable file
·38 lines (37 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
set -e
SCRIPTPATH=$(dirname "$BASH_SOURCE")
pushd $SCRIPTPATH > /dev/null
for i in "$@" ; do
case $1 in
--help)
echo "Usage: ./fmt [--all] [ARGS]"
echo " All other [ARGS] are forwarded to rustfmt; see below"
echo "Option:"
echo " --all Fmt all .rs files (default is to fmt files with changes from origin/master)"
echo
rustfmt --help
exit 0
;;
--all)
ARGS=$(git ls-files '*.rs')
NO_DEFAULT_FILES=1
shift
;;
-*)
ARGS+=" $i"
shift
;;
*)
ARGS+=" $i"
NO_DEFAULT_FILES=1
shift
;;
esac
done
if [ ! "$NO_DEFAULT_FILES" ] ; then
FILES=$(git diff --name-only origin/master '*.rs')
[ "$FILES" ] || exit 0
fi
rustfmt $ARGS $FILES
popd > /dev/null