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

rust: add a rustfmt formatting script

parent 6994b1cf
#!/bin/sh
# 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"
shift
if ! [ -f "$path" ]; then
echo >&2 'error: could not find file to format: '"$path"
exit 4
fi
if ! which "rustfmt" > /dev/null; then
echo >&2 'error: could not find the `rustfmt` binary'
exit 3
fi
if ! [ -f ".rustfmt.toml" ] && ! [ -f "rustfmt.toml" ]; then
echo >&2 'error: a `rustfmt.toml` file is missing'
exit 2
fi
exec rustfmt --write-mode=overwrite --skip-children "$path"
formatter_rustfmt:
kind: "rustfmt"
script: "/PATH/TO/format.rustfmt"
required_files:
- ".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