contrib: Add color to paccache

Signed-off-by: William Giokas <1007380@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
William Giokas 2013-03-05 17:05:08 -06:00 committed by Allan McRae
parent 6e0c47d22f
commit d90641a894

View file

@ -27,23 +27,16 @@ declare -a candidates=() cmdopts=() whitelist=() blacklist=()
declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0 declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0
declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch= declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch=
msg() { USE_COLOR='y'
local mesg=$1; shift
printf "==> $mesg\n" "$@"
} >&2
error() { m4_include(../scripts/library/output_format.sh)
local mesg=$1; shift m4_include(../scripts/library/parseopts.sh)
printf "==> ERROR: $mesg\n" "$@"
} >&2
die() { die() {
error "$@" error "$@"
exit 1 exit 1
} }
m4_include(../scripts/library/parseopts.sh)
# reads a list of files on stdin and prints out deletion candidates # reads a list of files on stdin and prints out deletion candidates
pkgfilter() { pkgfilter() {
# there's whitelist and blacklist parameters passed to this # there's whitelist and blacklist parameters passed to this
@ -179,6 +172,7 @@ containing pacman package tarballs.
-i, --ignore <pkgs> ignore 'pkgs', comma separated. Alternatively, specify '-' to -i, --ignore <pkgs> ignore 'pkgs', comma separated. Alternatively, specify '-' to
read package names from stdin, newline delimited. read package names from stdin, newline delimited.
-k, --keep <num> keep 'num' of each package in 'cachedir' (default: 3). -k, --keep <num> keep 'num' of each package in 'cachedir' (default: 3).
--nocolor remove color from output.
-u, --uninstalled target uninstalled packages. -u, --uninstalled target uninstalled packages.
-v, --verbose increase verbosity. specify up to 3 times. -v, --verbose increase verbosity. specify up to 3 times.
-z, --null use null delimiters for candidate names (only with -v and -vv) -z, --null use null delimiters for candidate names (only with -v and -vv)
@ -193,7 +187,7 @@ version() {
OPT_SHORT=':a:c:dfhi:k:m:rsuVvz' OPT_SHORT=':a:c:dfhi:k:m:rsuVvz'
OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move' OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
'remove' 'uninstalled' 'version' 'verbose' 'null') 'nocolor' 'remove' 'uninstalled' 'version' 'verbose' 'null')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1 exit 1
@ -233,6 +227,8 @@ while :; do
keep=$(( 10#$keep )) keep=$(( 10#$keep ))
fi fi
shift ;; shift ;;
--nocolor)
USE_COLOR='n' ;;
-m|--move) -m|--move)
move=1 movedir=$2 move=1 movedir=$2
shift ;; shift ;;
@ -256,6 +252,8 @@ while :; do
shift shift
done done
m4_include(../scripts/library/term_colors.sh)
# remaining args are a whitelist # remaining args are a whitelist
whitelist=("$@") whitelist=("$@")