Commit fe43871a authored by Ben Boeckel's avatar Ben Boeckel
Browse files

rust: add a rustfmt formatting script

parent 6994b1cf
# This formatter uses the `rustfmt` tool to perform formatting of
# files written in the Rust language.
# It uses the `rustfmt` executable in `$PATH` and checks for
# the existence for either of the `rustfmt.toml` or
# `.rustfmt.toml` files as its configuration.
set -e
readonly path="$1"
if ! [ -f "$path" ]; then
echo >&2 'error: could not find file to format: '"$path"
exit 4
if ! which "rustfmt" > /dev/null; then
echo >&2 'error: could not find the `rustfmt` binary'
exit 3
if ! [ -f ".rustfmt.toml" ] && ! [ -f "rustfmt.toml" ]; then
echo >&2 'error: a `rustfmt.toml` file is missing'
exit 2
exec rustfmt --write-mode=overwrite --skip-children "$path"
kind: "rustfmt"
script: "/PATH/TO/format.rustfmt"
- ".rustfmt.toml"
- "rustfmt.toml"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment