cratefmt alias

This commit is contained in:
Thomas Forgione 2019-05-18 13:00:05 +02:00
parent bc7c90245f
commit d666330b67
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
1 changed files with 19 additions and 0 deletions

View File

@ -69,4 +69,23 @@ _cdg() {
_arguments "1: :($( cat $GCLONE_PATH/.cdgcache | rev | cut -d '/' -f 1 | rev))"
}
cratefmt() {
local current_dir=$PWD
# Find cargo.toml
while [ ! -f Cargo.toml ] && [ $PWD != "/" ]; do
cd ..
done
if [ -f Cargo.toml ]; then
rustfmt --edition 2018 `find src -name "*.rs"`
else
echo -e "\033[1;31merror:\033[0m\033[1m can't find Cargo.toml\033[0m"
cd $current_dir
return 1
fi
cd $current_dir
}
compdef _cdg cdg