[pacman-dev] [PATCHv2 09/10] contrib: add color to paccache

William Giokas 1007380 at gmail.com
Sun Mar 3 13:48:24 EST 2013


a much simpler change than bacman, as it already used 'msg' and 'error',
just without the option of color.

Signed-off-by: William Giokas <1007380 at gmail.com>
---

Note, paccache already has a -m option, so I just left it without a short
opt.

 contrib/paccache.sh.in | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
index 46eb230..483f5eb 100644
--- a/contrib/paccache.sh.in
+++ b/contrib/paccache.sh.in
@@ -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    cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch=
 
-msg() {
-	local mesg=$1; shift
-	printf "==> $mesg\n" "$@"
-} >&2
+USE_COLOR='y'
 
-error() {
-	local mesg=$1; shift
-	printf "==> ERROR: $mesg\n" "$@"
-} >&2
+m4_include(../scripts/library/output_format.sh)
+m4_include(../scripts/library/parseopts.sh)
 
 die() {
 	error "$@"
 	exit 1
 }
 
-m4_include(../scripts/library/parseopts.sh)
-
 # reads a list of files on stdin and prints out deletion candidates
 pkgfilter() {
 	# there's whitelist and blacklist parameters passed to this
@@ -193,7 +186,7 @@ version() {
 
 OPT_SHORT=':a:c:dfhi:k:m:rsuVvz'
 OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
-          'remove' 'uninstalled' 'version' 'verbose' 'null')
+          'no-color' 'remove' 'uninstalled' 'version' 'verbose' 'null')
 
 if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 	exit 1
@@ -233,6 +226,8 @@ while :; do
 				keep=$(( 10#$keep ))
 			fi
 			shift ;;
+		--no-color)
+			USE_COLOR='n' ;;
 		-m|--move)
 			move=1 movedir=$2
 			shift ;;
@@ -256,6 +251,8 @@ while :; do
 	shift
 done
 
+m4_include(../scripts/library/term_colors.sh)
+
 # remaining args are a whitelist
 whitelist=("$@")
 
-- 
1.8.2.rc1.24.g06d67b8



More information about the pacman-dev mailing list