Note why I chose 'rm -rf' instead of 'cargo clean'
[khome.git] / home / bin / cargo-clean-all
1 #! /bin/bash
2
3 N_CPUS=$(nproc 2> /dev/null || gnproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null)
4
5 main() {
6 local -r dir="${1-$HOME}"
7 local -r jobs="${1-$N_CPUS}"
8
9 # XXX Just doing 'rm -rf' because 'cargo clean' starts doing extra work
10 # and in some cases even downloads new deps, etc.
11 find "$dir" -type f -name Cargo.toml -print0 \
12 | xargs -0 -I % -P "$jobs" sh -c 'rm -rf $(dirname "%")/target'
13 }
14
15 main "$@"
This page took 0.058178 seconds and 4 git commands to generate.