autospec, autospec.conf, plugins: replace the option '--colorize' by '--colors <color-theme>'

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-11-11 18:56:52 +01:00
parent ac3e9bc14b
commit a2056ba9d5
16 changed files with 60 additions and 92 deletions

View File

@ -41,6 +41,10 @@ Changes in version 1.14.2
* configuration - Davide Madrisan: * configuration - Davide Madrisan:
Add 'color-theme.none'. This theme can be used to disable color themes. Add 'color-theme.none'. This theme can be used to disable color themes.
+ update
* autospec, autospec.conf, plugins/* - Davide Madrisan:
Replace the option '--colorize' by '--colors <color-theme>'.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Changes in version 1.14.1 - _TO*Hacklab release Changes in version 1.14.1 - _TO*Hacklab release

View File

@ -62,8 +62,7 @@ function autospec.usage() {
-h, --help "$"Print this help, then exit"" -h, --help "$"Print this help, then exit""
-V, --version "$"Print version number, then exit"" -V, --version "$"Print version number, then exit""
-q, --quiet "$"Run in quiet mode"" -q, --quiet "$"Run in quiet mode""
-r, --colorize "$"Enable the colorized output"" --colors "$"Select the theme to be used for the colorized output""
--colorize-theme "$"Select the theme to be used for the colorized output""
-D, --debug "$"Run in debugging mode (very verbose output)"" -D, --debug "$"Run in debugging mode (very verbose output)""
"$"Usage"": "$"Usage"":
@ -91,6 +90,8 @@ notify.disable_colors
{ echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2 { echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2
exit 1; } exit 1; }
. @libdir@/libcfg.lib
# Little helper function for reading args from the commandline. # Little helper function for reading args from the commandline.
# it automatically handles -a b and -a=b variants, and returns 1 if # it automatically handles -a b and -a=b variants, and returns 1 if
# we need to shift $3. # we need to shift $3.
@ -127,12 +128,12 @@ while (($# > 0)); do
-q|--quiet) -q|--quiet)
let "verbose = 0" ;; let "verbose = 0" ;;
-r|--colorize) -r|--colorize)
let "colorize = 1"
notify.warning $"\ notify.warning $"\
deprecated option"" (-r|--colorize), "$"use \`--colorize-theme' instead" ;; deprecated option"" \`-r|--colorize': "$"use \`--colors' instead"
--colorize-theme) # for backward compatibility
read_arg colorize_theme "$@" || shift color_scheme="default" ;;
let "colorize = 1" ;; --colors)
read_arg color_scheme "$@" || shift ;;
-h|--help) -h|--help)
let "print_help = 1" ;; let "print_help = 1" ;;
-V|--version) -V|--version)
@ -143,7 +144,7 @@ deprecated option"" (-r|--colorize), "$"use \`--colorize-theme' instead" ;;
done done
notify.debug "[${me[0]}, "$"version"" ${me[1]}]" notify.debug "[${me[0]}, "$"version"" ${me[1]}]"
notify.debug "colorize_theme = \"$colorize_theme\"" notify.debug "color_scheme = \"$color_scheme\""
case "$(( $pck_update + $spec_create + $pck_extract + $config_getvar ))" in case "$(( $pck_update + $spec_create + $pck_extract + $config_getvar ))" in
0) [ "$print_help" = "1" ] && autospec.usage 0 0) [ "$print_help" = "1" ] && autospec.usage 0
@ -159,11 +160,8 @@ case "$(( $pck_update + $spec_create + $pck_extract + $config_getvar ))" in
*) autospec.usage 1 ;; *) autospec.usage 1 ;;
esac esac
. @libdir@/libcfg.lib [ "$logging" = "1" ] && color_scheme="none"
notify.enable_colors "$color_scheme"
[ "$logging" = "1" ] && let "colorize = 0"
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \
|| notify.disable_colors
# checking for errors in the configuration file # checking for errors in the configuration file
[ "$config_getvar" = 1 ] || config.integrity [ "$config_getvar" = 1 ] || config.integrity

View File

@ -39,8 +39,9 @@ pck_confs := autospec.conf \
pck_confs_infiles := $(wildcard *.in) pck_confs_infiles := $(wildcard *.in)
pck_color_themes := color-theme.terminal-dark \ pck_color_themes := color-theme.default \
color-theme.terminal-white color-theme.web color-theme.none color-theme.terminal-dark color-theme.terminal-white color-theme.web \
color-theme.none
all: all:

View File

@ -43,7 +43,7 @@ spec_backup_attr="hidden"
# EXIT="${ESC}[1;31m" # EXIT="${ESC}[1;31m"
# NORM=$(echo -en "${ESC}[m\017") # NORM=$(echo -en "${ESC}[m\017")
# See the files: see /etc/@package@.d/color-theme.* # See the files: see /etc/@package@.d/color-theme.*
colorize=1 color_scheme="default"
## Logging directory (default is /var/tmp/@package@) -------------------------- ## Logging directory (default is /var/tmp/@package@) --------------------------
logging_dir="/var/tmp/@package@" logging_dir="/var/tmp/@package@"

9
conf/color-theme.default Normal file
View File

@ -0,0 +1,9 @@
#
# color scheme "terminal-dark"
#
ESC=$(echo -en "\033") # ascii ESCape
CRIT="${ESC}[1;31m" # switch on red
NOTE="${ESC}[1;33m" # switch on yellow
WARN="${ESC}[1;31m"
EXIT="${ESC}[1;31m"
NORM=$(echo -en "${ESC}[m\017")

View File

@ -50,15 +50,14 @@ function notify.note() {
# args: # args:
# none # none
function notify.enable_colors() { function notify.enable_colors() {
local colorize_theme="$1" local color_scheme="$1"
# for backward compatibility [ "$color_scheme" ] || color_scheme="default"
[ "$colorize_theme" ] || colorize_theme="terminal-dark" if [ -r /etc/@package@.d/color-theme.${color_scheme} ]; then
. /etc/@package@.d/color-theme.${color_scheme}
if [ -r /etc/@package@.d/color-theme.${colorize_theme} ]; then notify.debug "loading /etc/@package@.d/color-theme.${color_scheme}"
. /etc/@package@.d/color-theme.${colorize_theme}
else else
notify.warning \ notify.warning \
$"unknown color theme \`$colorize_theme': colors will be disabled" $"unknown color theme \`$color_scheme': colors will be disabled"
ESC= CRIT= NOTE= WARN= EXIT= NORM= ESC= CRIT= NOTE= WARN= EXIT= NORM=
fi fi
} }

View File

@ -13,8 +13,6 @@ me=(${0##*/} "@version@" "@date@")
. @libdir@/libmsgmng.lib . @libdir@/libmsgmng.lib
# default values: # default values:
# - colorized output (disabled by default)
let "colorize = 0"
# - output verbosity # - output verbosity
let "verbose = 1" let "verbose = 1"
@ -63,8 +61,7 @@ function usage() {
-h, --help "$"Print this help, then exit"" -h, --help "$"Print this help, then exit""
-V, --version "$"Print version number, then exit"" -V, --version "$"Print version number, then exit""
-q, --quiet "$"Run in quiet mode"" -q, --quiet "$"Run in quiet mode""
-r, --colorize "$"Enable the colorized output"" --colors "$"Select the theme to be used for the colorized output""
--colorize-theme "$"Select the theme to be used for the colorized output""
-D, --debug "$"Run in debugging mode (very verbose output)"" -D, --debug "$"Run in debugging mode (very verbose output)""
"$"Samples"": "$"Samples"":
@ -97,7 +94,7 @@ done
exec_options=`LC_ALL=C getopt \ exec_options=`LC_ALL=C getopt \
-o C:DqrhV \ -o C:DqrhV \
--long eval:,config:,\ --long eval:,config:,\
debug,quiet,colorize,colorize-theme:,help,version,\ debug,quiet,colors:,help,version,\
frontend_opts: \ frontend_opts: \
-n "$me" -- "$@"` -n "$me" -- "$@"`
[ $? = 0 ] || exit 1 [ $? = 0 ] || exit 1
@ -115,11 +112,8 @@ while :; do
let "verbose = 2" ;; let "verbose = 2" ;;
-q|--quiet) -q|--quiet)
let "verbose = 0" ;; let "verbose = 0" ;;
-r|--colorize) --colors)
let "colorize = 1" ;; color_scheme="$2"; shift ;;
--colorize-theme)
colorize_theme="$2"; shift
let "colorize = 1" ;;
-h|--help) -h|--help)
usage 0 ;; usage 0 ;;
-V|--version) -V|--version)
@ -135,8 +129,7 @@ for arg in $@; do
notify.error $"unrecognized option"" -- \`$arg'" notify.error $"unrecognized option"" -- \`$arg'"
done done
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ notify.enable_colors "$color_scheme"
|| notify.disable_colors
# config.getvar() # config.getvar()
# Parameters: # Parameters:

View File

@ -13,8 +13,6 @@ me=(${0##*/} "@version@" "@date@")
. @libdir@/libmsgmng.lib . @libdir@/libmsgmng.lib
# default values: # default values:
# - colorized output (disabled by default)
let "colorize = 0"
# - output verbosity # - output verbosity
let "verbose = 1" let "verbose = 1"
@ -67,8 +65,7 @@ function usage() {
-h, --help "$"Print this help, then exit"" -h, --help "$"Print this help, then exit""
-V, --version "$"Print version number, then exit"" -V, --version "$"Print version number, then exit""
-q, --quiet "$"Run in quiet mode"" -q, --quiet "$"Run in quiet mode""
-r, --colorize "$"Enable the colorized output"" --colors "$"Select the theme to be used for the colorized output""
--colorize-theme "$"Select the theme to be used for the colorized output""
-D, --debug "$"Run in debugging mode (very verbose output)"" -D, --debug "$"Run in debugging mode (very verbose output)""
"$"Samples"": "$"Samples"":
@ -102,7 +99,7 @@ exec_options=`LC_ALL=C getopt \
-o xF:DqrhV \ -o xF:DqrhV \
--long \ --long \
extract,files:,destdir:,\ extract,files:,destdir:,\
debug,quiet,colorize,colorize-theme:,help,version,\ debug,quiet,colors:,help,version,\
frontend_opts: \ frontend_opts: \
-n "$me" -- "$@"` -n "$me" -- "$@"`
[ $? = 0 ] || exit 1 [ $? = 0 ] || exit 1
@ -121,11 +118,8 @@ while :; do
let "verbose = 2" ;; let "verbose = 2" ;;
-q|--quiet) -q|--quiet)
let "verbose = 0" ;; let "verbose = 0" ;;
-r|--colorize) --colors)
let "colorize = 1" ;; color_scheme="$2"; shift ;;
--colorize-theme)
colorize_theme="$2"; shift
let "colorize = 1" ;;
-h|--help) -h|--help)
usage 0 ;; usage 0 ;;
-V|--version) -V|--version)
@ -141,8 +135,7 @@ for arg in $@; do
notify.error $"unrecognized option"" -- \`$arg'" notify.error $"unrecognized option"" -- \`$arg'"
done done
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ notify.enable_colors "$color_scheme"
|| notify.disable_colors
# s_rpm_pck : the name of the srpm package (local or remote) # s_rpm_pck : the name of the srpm package (local or remote)
# (i.e. /usr/src/RPM/SRPMS/automake-1.9-1qilnx.src.rpm) # (i.e. /usr/src/RPM/SRPMS/automake-1.9-1qilnx.src.rpm)

View File

@ -31,8 +31,6 @@ me=(${0##*/} "@version@" "@date@")
. @libdir@/libapse.lib . @libdir@/libapse.lib
# default values: # default values:
# colorized output (disabled by default)
let "colorize = 0"
# output verbosity # output verbosity
let "verbose = 1" let "verbose = 1"
# #
@ -153,8 +151,7 @@ function usage() {
-h, --help "$"Print this help, then exit"" -h, --help "$"Print this help, then exit""
-V, --version "$"Print version number, then exit"" -V, --version "$"Print version number, then exit""
-q, --quiet "$"Run in quiet mode"" -q, --quiet "$"Run in quiet mode""
-r, --colorize "$"Enable the colorized output"" --colors "$"Select the theme to be used for the colorized output""
--colorize-theme "$"Select the theme to be used for the colorized output""
-D, --debug "$"Run in debugging mode (very verbose output)"" -D, --debug "$"Run in debugging mode (very verbose output)""
"$"Samples"": "$"Samples"":
@ -197,7 +194,7 @@ server-download:,server-upload:,server:,\
changelog:,nosrpm,norpm,list-check,update-autobuildreq,\ changelog:,nosrpm,norpm,list-check,update-autobuildreq,\
force-update,force-build,force-install,force-download,force,\ force-update,force-build,force-install,force-download,force,\
ignore-test:,clear,format,log,rebuild,root:,\ ignore-test:,clear,format,log,rebuild,root:,\
debug,quiet,colorize,colorize-theme:,help,version,\ debug,quiet,colors:,help,version,\
frontend_opts: \ frontend_opts: \
-n "$me" -- "$@"` -n "$me" -- "$@"`
[ $? = 0 ] || exit 1 [ $? = 0 ] || exit 1
@ -277,11 +274,8 @@ while :; do
let "verbose = 2" ;; let "verbose = 2" ;;
-q|--quiet) -q|--quiet)
let "verbose = 0" ;; let "verbose = 0" ;;
-r|--colorize) --colors)
let "colorize = 1" ;; color_scheme="$2"; shift ;;
--colorize-theme)
colorize_theme="$2"; shift
let "colorize = 1" ;;
-h|--help) -h|--help)
usage 0 ;; usage 0 ;;
-V|--version) -V|--version)
@ -312,10 +306,8 @@ if [ -n "$rpm_rootdir" ]; then
notify.error $"no such file or directory"": $rpm_rootdir" notify.error $"no such file or directory"": $rpm_rootdir"
fi fi
[ "$logging" = "1" ] && let "colorize = 0" [ "$logging" = "1" ] && color_scheme="none"
notify.enable_colors "$color_scheme"
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \
|| notify.disable_colors
# default values for non mandatory configuration variables # default values for non mandatory configuration variables
[ "$logging_dir" ] || logging_dir="${tmppath_dir:-/var/tmp}/@package@" [ "$logging_dir" ] || logging_dir="${tmppath_dir:-/var/tmp}/@package@"

View File

@ -18,8 +18,6 @@ me=(${0##*/} "@version@" "@date@")
. @libdir@/libnetwork.lib . @libdir@/libnetwork.lib
# set default variables # set default variables
# colorized output (disabled by default)
let "colorize = 0"
# output verbosity # output verbosity
let "verbose = 1" let "verbose = 1"
@ -120,8 +118,7 @@ function usage() {
-h, --help "$"Print this help, then exit"" -h, --help "$"Print this help, then exit""
-V, --version "$"Print version number, then exit"" -V, --version "$"Print version number, then exit""
-q, --quiet "$"Run in quiet mode"" -q, --quiet "$"Run in quiet mode""
-r, --colorize "$"Enable the colorized output"" --colors "$"Select the theme to be used for the colorized output""
--colorize-theme "$"Select the theme to be used for the colorized output""
-D, --debug "$"Run in debugging mode (very verbose output)"" -D, --debug "$"Run in debugging mode (very verbose output)""
"$"Samples"": "$"Samples"":
@ -163,7 +160,7 @@ exec_options=`LC_ALL=C getopt \
--long \ --long \
source:,pck-name:,pck-version:,type:,output:,changelog:,\ source:,pck-name:,pck-version:,type:,output:,changelog:,\
git-branch:,preserve-dot-git,\ git-branch:,preserve-dot-git,\
debug,quiet,colorize,colorize-theme:,help,version,\ debug,quiet,colors:,help,version,\
frontend_opts: \ frontend_opts: \
-n "$me" -- "$@"` -n "$me" -- "$@"`
[ $? = 0 ] || exit 1 [ $? = 0 ] || exit 1
@ -196,11 +193,8 @@ while :; do
let "verbose = 2" ;; let "verbose = 2" ;;
-q|--quiet) -q|--quiet)
let "verbose = 0" ;; let "verbose = 0" ;;
-r|--colorize) --colors)
let "colorize = 1" ;; color_scheme="$2"; shift ;;
--colorize-theme)
colorize_theme="$2"; shift
let "colorize = 1" ;;
-h|--help) -h|--help)
usage 0 ;; usage 0 ;;
-V|--version) -V|--version)
@ -211,8 +205,7 @@ while :; do
shift shift
done done
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ notify.enable_colors "$color_scheme"
|| notify.disable_colors
for arg in $@; do for arg in $@; do
notify.error $"unrecognized option"" -- \`$arg'" notify.error $"unrecognized option"" -- \`$arg'"

View File

@ -55,9 +55,6 @@ msgstr "Stampa il numero di versione e termina il programma"
msgid "Run in quiet mode" msgid "Run in quiet mode"
msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione" msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione"
msgid "Enable the colorized output"
msgstr "Abilita l'output colorato"
msgid "Select the theme to be used for the colorized output" msgid "Select the theme to be used for the colorized output"
msgstr "Seleziona il tema da usare per generare l'output colorato" msgstr "Seleziona il tema da usare per generare l'output colorato"
@ -79,8 +76,8 @@ msgstr "libreria non trovata"
msgid "deprecated option" msgid "deprecated option"
msgstr "opzione deprecata" msgstr "opzione deprecata"
msgid "use \\`--colorize-theme' instead" msgid "use \\`--colors' instead"
msgstr "utilizzare invece \\`--colorize-theme'" msgstr "utilizzare \\`--colors'"
msgid "version" msgid "version"
msgstr "versione" msgstr "versione"

View File

@ -66,9 +66,6 @@ msgstr "Stampa il numero di versione e termina il programma"
msgid "Run in quiet mode" msgid "Run in quiet mode"
msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione" msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione"
msgid "Enable the colorized output"
msgstr "Abilita l'output colorato"
msgid "Select the theme to be used for the colorized output" msgid "Select the theme to be used for the colorized output"
msgstr "Seleziona il tema da usare per generare l'output colorato" msgstr "Seleziona il tema da usare per generare l'output colorato"

View File

@ -22,5 +22,6 @@ msgstr "questo script richiede bash versione 2 o superiore"
msgid "no message" msgid "no message"
msgstr "nessun messaggio" msgstr "nessun messaggio"
msgid "unknown color theme \\`$colorize_theme': colors will be disabled" msgid "unknown color theme \\`$color_scheme': colors will be disabled"
msgstr "tema di colori sconosciuto \\`$colorize_theme': output con colori disabilitato" msgstr "tema di colori sconosciuto \\`$color_scheme': output con colori disabilitato"

View File

@ -63,9 +63,6 @@ msgstr "Stampa il numero di versione e termina il programma"
msgid "Run in quiet mode" msgid "Run in quiet mode"
msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione" msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione"
msgid "Enable the colorized output"
msgstr "Abilita l'output colorato"
msgid "Select the theme to be used for the colorized output" msgid "Select the theme to be used for the colorized output"
msgstr "Seleziona il tema da usare per generare l'output colorato" msgstr "Seleziona il tema da usare per generare l'output colorato"

View File

@ -180,9 +180,6 @@ msgstr "Stampa il numero di versione e termina il programma"
msgid "Run in quiet mode" msgid "Run in quiet mode"
msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione" msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione"
msgid "Enable the colorized output"
msgstr "Abilita l'output colorato"
msgid "Select the theme to be used for the colorized output" msgid "Select the theme to be used for the colorized output"
msgstr "Seleziona il tema da usare per generare l'output colorato" msgstr "Seleziona il tema da usare per generare l'output colorato"

View File

@ -100,9 +100,6 @@ msgstr "Stampa il numero di versione e termina il programma"
msgid "Run in quiet mode" msgid "Run in quiet mode"
msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione" msgstr "Non stampa alcun dettaglio delle operazioni in esecuzione"
msgid "Enable the colorized output"
msgstr "Abilita l'output colorato"
msgid "Select the theme to be used for the colorized output" msgid "Select the theme to be used for the colorized output"
msgstr "Seleziona il tema da usare per generare l'output colorato" msgstr "Seleziona il tema da usare per generare l'output colorato"