home
/
code
/
khome.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
70dc9e9
)
Add cargo space dir listing option
author
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 24 Jan 2023 17:56:34 +0000
(12:56 -0500)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 24 Jan 2023 17:56:34 +0000
(12:56 -0500)
home/bin/cargo-space
patch
|
blob
|
blame
|
history
diff --git
a/home/bin/cargo-space
b/home/bin/cargo-space
index
624c08d
..
3e936ec
100755
(executable)
--- a/
home/bin/cargo-space
+++ b/
home/bin/cargo-space
@@
-2,6
+2,7
@@
total_cargo_build_space() {
local -r dir="$1"
total_cargo_build_space() {
local -r dir="$1"
+ local -r list="$2"
local cargo_toml_path
local target_path
local cargo_toml_path
local target_path
@@
-12,16
+13,49
@@
total_cargo_build_space() {
target_path=$(dirname "$cargo_toml_path")/target;
if test -d "$target_path"
then
target_path=$(dirname "$cargo_toml_path")/target;
if test -d "$target_path"
then
- du -s "$target_path"; fi
- done \
- | awk '{tot += $1} END {print tot * 1024}' \
- | numfmt --to=iec
+ if [[ "$list" -eq 1 ]]
+ then
+ du -sh "$target_path"
+ else
+ du -s "$target_path"
+ fi
+ fi
+ done \
+ | if [[ "$list" -eq 1 ]]
+ then
+ sort -h -k 1
+ else
+ awk '{tot += $1} END {print tot * 1024}' | numfmt --to=iec
+ fi
}
main() {
}
main() {
- local -r dir="${1-$HOME}"
+ local dir="$HOME"
+ local list=0
+ local arg
- total_cargo_build_space "$dir"
+ while :
+ do
+ arg="$1"
+ case "$arg" in
+ '')
+ break
+ ;;
+ -l | --list)
+ list=1
+ shift
+ ;;
+ -*)
+ printf 'Unknown flag: "%s"\n' "$arg" >&2
+ exit 1
+ ;;
+ *)
+ dir="$arg"
+ shift
+ esac
+ done
+
+ total_cargo_build_space "$dir" "$list"
}
main "$@"
}
main "$@"
This page took
0.030998 seconds
and
4
git commands to generate.