28 lines
611 B
Bash
28 lines
611 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Format toutes les crates du workspace logique (chacune autonome, pas de
|
||
|
|
# Cargo.toml racine — voir README pour la raison).
|
||
|
|
#
|
||
|
|
# Usage :
|
||
|
|
# ./fmt.sh # format
|
||
|
|
# ./fmt.sh --check # CI mode : exit 1 si non formatté
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
cd "$(dirname "$0")"
|
||
|
|
|
||
|
|
CHECK_FLAG=""
|
||
|
|
if [[ "${1:-}" == "--check" ]]; then
|
||
|
|
CHECK_FLAG="--check"
|
||
|
|
fi
|
||
|
|
|
||
|
|
fail=0
|
||
|
|
for crate in crates/*/; do
|
||
|
|
if [[ -f "$crate/Cargo.toml" ]]; then
|
||
|
|
echo "==> $crate"
|
||
|
|
if ! cargo fmt --manifest-path "$crate/Cargo.toml" -- $CHECK_FLAG; then
|
||
|
|
fail=1
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
exit $fail
|