Experiment scaling via launch of mate-settings-daemon
[khome.git] / home / bin / cargo-space
CommitLineData
6625ae53
SK
1#! /bin/bash
2
3total_cargo_build_space() {
4 local -r dir="$1"
40f866e4 5 local -r list="$2"
6625ae53
SK
6
7 local cargo_toml_path
8 local target_path
9
10 find "$dir" -type f -name Cargo.toml \
11 | while read -r cargo_toml_path
12 do
13 target_path=$(dirname "$cargo_toml_path")/target;
14 if test -d "$target_path"
15 then
40f866e4
SK
16 if [[ "$list" -eq 1 ]]
17 then
18 du -sh "$target_path"
19 else
20 du -s "$target_path"
21 fi
22 fi
23 done \
24 | if [[ "$list" -eq 1 ]]
25 then
26 sort -h -k 1
27 else
28 awk '{tot += $1} END {print tot * 1024}' | numfmt --to=iec
29 fi
6625ae53
SK
30}
31
32main() {
40f866e4
SK
33 local dir="$HOME"
34 local list=0
35 local arg
6625ae53 36
40f866e4
SK
37 while :
38 do
39 arg="$1"
40 case "$arg" in
41 '')
42 break
43 ;;
44 -l | --list)
45 list=1
46 shift
47 ;;
48 -*)
49 printf 'Unknown flag: "%s"\n' "$arg" >&2
50 exit 1
51 ;;
52 *)
53 dir="$arg"
54 shift
55 esac
56 done
57
58 total_cargo_build_space "$dir" "$list"
6625ae53
SK
59}
60
61main "$@"
This page took 0.034677 seconds and 4 git commands to generate.