Skip to content

Commit 7b2c8c8

Browse files
authored
Fix format.sh -f printing usage (#1767)
1 parent 3a78b54 commit 7b2c8c8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

scripts/format.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ function usage() {
2525
echo >&2 " $0 -[f|l]"
2626
echo >&2 ""
2727
echo >&2 "Options:"
28-
echo >&2 " -f Format source code in place"
28+
echo >&2 " -f Format source code in place (default)"
2929
echo >&2 " -l Lint check without formatting the source code"
3030
}
3131

32+
format=true
3233
lint=false
33-
while getopts ":lh" opt; do
34+
while getopts ":flh" opt; do
3435
case "$opt" in
36+
f)
37+
format=true
38+
lint=false
39+
;;
3540
l)
41+
format=false
3642
lint=true
3743
;;
3844
h)
@@ -99,7 +105,7 @@ if "$lint"; then
99105
fi
100106

101107
log "Ran swift-format lint with no errors."
102-
else
108+
elif "$format"; then
103109
"${SWIFTFORMAT_BIN}" format \
104110
--parallel --recursive --in-place \
105111
"${REPO}/Sources" "${REPO}/Tests" \
@@ -110,4 +116,6 @@ else
110116
fi
111117

112118
log "Ran swift-format with no errors."
119+
else
120+
fatal "No actions taken."
113121
fi

0 commit comments

Comments
 (0)