[pacman-dev] [PATCHv2 07/10] scripts: add color to repo-add

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


Use color by default, use -m or --no-color to suppress colorized output.

Signed-off-by: William Giokas <1007380 at gmail.com>
---
 doc/repo-add.8.txt     | 3 +++
 scripts/repo-add.sh.in | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/doc/repo-add.8.txt b/doc/repo-add.8.txt
index 91f3ac6..2bb9acd 100644
--- a/doc/repo-add.8.txt
+++ b/doc/repo-add.8.txt
@@ -57,6 +57,9 @@ Common Options
 	If the signature is invalid, an error is produced and the update does not
 	proceed.
 
+*-m, \--no-color*::
+	Remove color from output of repo-add or repo-remove.
+
 repo-add Options
 ----------------
 *-d, \--delta*::
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 3e18a1a..deee0f1 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -37,6 +37,7 @@ VERIFY=0
 REPO_DB_FILE=
 LOCKFILE=
 CLEAN_LOCK=0
+USE_COLOR='y'
 
 # ensure we have a sane umask set
 umask 0022
@@ -71,6 +72,7 @@ packages to remove can be specified on the command line.\n")"
 		printf -- "$(gettext "Please move along, there is nothing to see here.\n")"
 		return
 	fi
+	printf -- "$(gettext "  -m, --no-color    remove color from output\n")"
 	printf -- "$(gettext "  -q, --quiet       minimize output\n")"
 	printf -- "$(gettext "  -s, --sign        sign database with GnuPG after update\n")"
 	printf -- "$(gettext "  -k, --key <key>   use the specified key to sign the database\n")"
@@ -610,6 +612,7 @@ while (( $# )); do
 		-d|--delta) DELTA=1;;
 		-n|--new) ONLYADDNEW=1;;
 		-f|--files) WITHFILES=1;;
+		-m|--no-color) USE_COLOR='n';;
 		-s|--sign)
 			check_gpg
 			SIGN=1
@@ -642,6 +645,8 @@ while (( $# )); do
 	shift
 done
 
+m4_include(library/term_colors.sh)
+
 REPO_DB_FILE=${args[0]}
 if [[ -z $REPO_DB_FILE ]]; then
 	usage
-- 
1.8.2.rc1.24.g06d67b8



More information about the pacman-dev mailing list