[pacman-dev] [PATCHv2 05/10] scripts: add color to pacman-optimize

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


Color enabled by default, turn off with -m or --no-color.

Signed-off-by: William Giokas <1007380 at gmail.com>
---
 scripts/pacman-optimize.sh.in | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
index 53ae1c7..262bdf8 100644
--- a/scripts/pacman-optimize.sh.in
+++ b/scripts/pacman-optimize.sh.in
@@ -24,6 +24,8 @@
 export TEXTDOMAIN='pacman-scripts'
 export TEXTDOMAINDIR='@localedir@'
 
+USE_COLOR='y'
+
 declare -r myver='@PACKAGE_VERSION@'
 
 eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
@@ -33,7 +35,7 @@ m4_include(library/output_format.sh)
 
 usage() {
 	printf "pacman-optimize (pacman) %s\n\n" "$myver"
-	printf -- "$(gettext "Usage: %s [pacman_db_root]")\n\n" "$0"
+	printf -- "$(gettext "Usage: %s [-m|--no-color] [pacman_db_root]")\n\n" "$0"
 	printf -- "$(gettext "\
 pacman-optimize is a little hack that should improve the performance\n\
 of pacman when reading/writing to its filesystem-based database.\n\n")"
@@ -84,6 +86,13 @@ if [[ $1 = "-V" || $1 = "--version" ]]; then
 	exit 0
 fi
 
+if [[ $1 = "-m" || $1 = "--no-color" ]]; then
+	USE_COLOR='n'
+	shift
+fi
+
+m4_include(library/term_colors.sh)
+
 if [[ -n $1 ]]; then
 	dbroot="$1"
 fi
-- 
1.8.2.rc1.24.g06d67b8



More information about the pacman-dev mailing list