paccache: added --quiet option

Less output, although errors and warnings will still be printed
(scripts/library/output_format.sh).

Cleaner to have -q,--quiet than >/dev/null in cron.

Signed-off-by: Maxim Andersson <thesilentboatman@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Maxim Andersson 2015-02-08 23:24:57 +01:00 committed by Allan McRae
parent dff6982c83
commit 68602f4931

View file

@ -27,6 +27,7 @@ declare -a cachedirs=() 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 delim=$'\n' keep=3 movedir= scanarch= declare delim=$'\n' keep=3 movedir= scanarch=
QUIET=0
USE_COLOR='y' USE_COLOR='y'
m4_include(../scripts/library/output_format.sh) m4_include(../scripts/library/output_format.sh)
@ -135,6 +136,8 @@ runcmd() {
} }
summarize() { summarize() {
(( QUIET )) && return
local -i filecount=$1; shift local -i filecount=$1; shift
local seenarch= seen= arch= name= local seenarch= seen= arch= name=
local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*' local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*'
@ -192,6 +195,7 @@ Usage: ${myname} <operation> [options] [targets...]
delimited. delimited.
-k, --keep <num> keep "num" of each package in the cache (default: 3). -k, --keep <num> keep "num" of each package in the cache (default: 3).
--nocolor remove color from output. --nocolor remove color from output.
-q, --quiet minimize 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 -z, --null use null delimiters for candidate names (only with -v
@ -205,9 +209,9 @@ version() {
echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>' echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
} }
OPT_SHORT=':a:c:dfhi:k:m:rsuVvz' OPT_SHORT=':a:c:dfhi:k:m:qrsuVvz'
OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move' OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
'nocolor' 'remove' 'uninstalled' 'version' 'verbose' 'null') 'nocolor' 'quiet' 'remove' 'uninstalled' 'version' 'verbose' 'null')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1 exit 1
@ -247,11 +251,13 @@ 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 ;;
--nocolor)
USE_COLOR='n' ;;
-q|--quiet)
QUIET=1 ;;
-r|--remove) -r|--remove)
delete=1 ;; delete=1 ;;
-u|--uninstalled) -u|--uninstalled)