dotfiles/bin/cfmt

13 lines
384 B
Bash
Executable File

#!/bin/bash
args=""
for cfg in rustfmt.toml .rustfmt.toml rustfmt.nightly.toml .rustfmt.nightly.toml rustfmt-nightly.toml .rustfmt-nightly.toml
do
[ "$cfg" == "rustfmt.nightly.toml" ] && args="+nightly $args"
[ -f $cfg ] && exec cargo $args fmt -- --config-path $cfg
done
# or if no files, fallback to my preferred format
exec cargo $args fmt -- --config imports_granularity=crate