Browse Source

Add --fail-fast option that returns after first failure

pull/19/head
Fredrik Ekre 1 year ago
parent
commit
4f45349109
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 12
      src/main.jl

12
src/main.jl

@ -54,6 +54,10 @@ function print_help()
Print the diff between the input and formatted output to stderr. Print the diff between the input and formatted output to stderr.
Requires `git` or `diff` to be installed. Requires `git` or `diff` to be installed.
--fail-fast
Exit immediately after the first error. Only applicable when formatting
multiple files in the same invocation.
--help --help
Print this message. Print this message.
@ -100,6 +104,7 @@ function main(argv)
inplace = false inplace = false
diff = false diff = false
check = false check = false
fail_fast = false
# Parse the arguments # Parse the arguments
while length(argv) > 0 while length(argv) > 0
@ -110,6 +115,8 @@ function main(argv)
quiet = true quiet = true
elseif x == "-v" || x == "--verbose" elseif x == "-v" || x == "--verbose"
verbose = true verbose = true
elseif x == "-v" || x == "--fail-fast"
fail_fast = true
elseif x == "-d" || x == "--diff" elseif x == "-d" || x == "--diff"
diff = true diff = true
elseif x == "-c" || x == "--check" elseif x == "-c" || x == "--check"
@ -262,7 +269,10 @@ function main(argv)
# Limit stacktrace to 5 frames because Runic uses recursion a lot and 5 should # Limit stacktrace to 5 frames because Runic uses recursion a lot and 5 should
# be enough to see where the error occurred. # be enough to see where the error occurred.
bt = stacktrace(catch_backtrace())[1:5] bt = stacktrace(catch_backtrace())[1:5]
panic(err, bt) rc = panic(err, bt)
if fail_fast
return rc
end
continue continue
end end

Loading…
Cancel
Save