Commit | Line | Data |
---|---|---|
6625ae53 SK |
1 | #! /bin/bash |
2 | ||
3 | total_cargo_build_space() { | |
4 | local -r dir="$1" | |
5 | ||
6 | local cargo_toml_path | |
7 | local target_path | |
8 | ||
9 | find "$dir" -type f -name Cargo.toml \ | |
10 | | while read -r cargo_toml_path | |
11 | do | |
12 | target_path=$(dirname "$cargo_toml_path")/target; | |
13 | if test -d "$target_path" | |
14 | then | |
15 | du -s "$target_path"; fi | |
16 | done \ | |
17 | | awk '{tot += $1} END {print tot * 1024}' \ | |
18 | | numfmt --to=iec | |
19 | } | |
20 | ||
21 | main() { | |
22 | local -r dir="${1-$HOME}" | |
23 | ||
24 | total_cargo_build_space "$dir" | |
25 | } | |
26 | ||
27 | main "$@" |