From a2056ba9d595a8b35e933951fc16b64bb721d9c1 Mon Sep 17 00:00:00 2001 From: Davide Madrisan Date: Sun, 11 Nov 2012 18:56:52 +0100 Subject: [PATCH] autospec, autospec.conf, plugins: replace the option '--colorize' by '--colors ' Signed-off-by: Davide Madrisan --- ChangeLog | 4 ++++ autospec.in | 24 +++++++++++------------- conf/Makefile | 5 +++-- conf/autospec.conf.in | 2 +- conf/color-theme.default | 9 +++++++++ lib/libmsgmng.lib.in | 13 ++++++------- plugins/config-getvar.in | 17 +++++------------ plugins/pck-extract.in | 17 +++++------------ plugins/pck-update.in | 20 ++++++-------------- plugins/spec-create.in | 17 +++++------------ po/it/autospec_fe.po | 7 ++----- po/it/config-getvar.po | 3 --- po/it/libmsgmng.po | 5 +++-- po/it/pck-extract.po | 3 --- po/it/pck-update.po | 3 --- po/it/spec-create.po | 3 --- 16 files changed, 60 insertions(+), 92 deletions(-) create mode 100644 conf/color-theme.default diff --git a/ChangeLog b/ChangeLog index d4a3ce2..410c668 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,10 @@ Changes in version 1.14.2 * configuration - Davide Madrisan: 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 '. + ------------------------------------------------------------------------------- Changes in version 1.14.1 - _TO*Hacklab release diff --git a/autospec.in b/autospec.in index 6acd27e..cbe8404 100644 --- a/autospec.in +++ b/autospec.in @@ -62,8 +62,7 @@ function autospec.usage() { -h, --help "$"Print this help, then exit"" -V, --version "$"Print version number, then exit"" -q, --quiet "$"Run in quiet mode"" - -r, --colorize "$"Enable the colorized output"" - --colorize-theme "$"Select the theme to be used for the colorized output"" + --colors "$"Select the theme to be used for the colorized output"" -D, --debug "$"Run in debugging mode (very verbose output)"" "$"Usage"": @@ -91,6 +90,8 @@ notify.disable_colors { echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2 exit 1; } +. @libdir@/libcfg.lib + # Little helper function for reading args from the commandline. # it automatically handles -a b and -a=b variants, and returns 1 if # we need to shift $3. @@ -127,12 +128,12 @@ while (($# > 0)); do -q|--quiet) let "verbose = 0" ;; -r|--colorize) - let "colorize = 1" notify.warning $"\ -deprecated option"" (-r|--colorize), "$"use \`--colorize-theme' instead" ;; - --colorize-theme) - read_arg colorize_theme "$@" || shift - let "colorize = 1" ;; +deprecated option"" \`-r|--colorize': "$"use \`--colors' instead" + # for backward compatibility + color_scheme="default" ;; + --colors) + read_arg color_scheme "$@" || shift ;; -h|--help) let "print_help = 1" ;; -V|--version) @@ -143,7 +144,7 @@ deprecated option"" (-r|--colorize), "$"use \`--colorize-theme' instead" ;; done 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 0) [ "$print_help" = "1" ] && autospec.usage 0 @@ -159,11 +160,8 @@ case "$(( $pck_update + $spec_create + $pck_extract + $config_getvar ))" in *) autospec.usage 1 ;; esac -. @libdir@/libcfg.lib - -[ "$logging" = "1" ] && let "colorize = 0" -[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ - || notify.disable_colors +[ "$logging" = "1" ] && color_scheme="none" +notify.enable_colors "$color_scheme" # checking for errors in the configuration file [ "$config_getvar" = 1 ] || config.integrity diff --git a/conf/Makefile b/conf/Makefile index 0c2660c..1135d81 100644 --- a/conf/Makefile +++ b/conf/Makefile @@ -39,8 +39,9 @@ pck_confs := autospec.conf \ pck_confs_infiles := $(wildcard *.in) -pck_color_themes := color-theme.terminal-dark \ - color-theme.terminal-white color-theme.web color-theme.none +pck_color_themes := color-theme.default \ + color-theme.terminal-dark color-theme.terminal-white color-theme.web \ + color-theme.none all: diff --git a/conf/autospec.conf.in b/conf/autospec.conf.in index 193c2ed..8876875 100644 --- a/conf/autospec.conf.in +++ b/conf/autospec.conf.in @@ -43,7 +43,7 @@ spec_backup_attr="hidden" # EXIT="${ESC}[1;31m" # NORM=$(echo -en "${ESC}[m\017") # See the files: see /etc/@package@.d/color-theme.* -colorize=1 +color_scheme="default" ## Logging directory (default is /var/tmp/@package@) -------------------------- logging_dir="/var/tmp/@package@" diff --git a/conf/color-theme.default b/conf/color-theme.default new file mode 100644 index 0000000..43d2fab --- /dev/null +++ b/conf/color-theme.default @@ -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") diff --git a/lib/libmsgmng.lib.in b/lib/libmsgmng.lib.in index 1b6b0fe..bae2b0f 100644 --- a/lib/libmsgmng.lib.in +++ b/lib/libmsgmng.lib.in @@ -50,15 +50,14 @@ function notify.note() { # args: # none function notify.enable_colors() { - local colorize_theme="$1" - # for backward compatibility - [ "$colorize_theme" ] || colorize_theme="terminal-dark" - - if [ -r /etc/@package@.d/color-theme.${colorize_theme} ]; then - . /etc/@package@.d/color-theme.${colorize_theme} + local color_scheme="$1" + [ "$color_scheme" ] || color_scheme="default" + if [ -r /etc/@package@.d/color-theme.${color_scheme} ]; then + . /etc/@package@.d/color-theme.${color_scheme} + notify.debug "loading /etc/@package@.d/color-theme.${color_scheme}" else 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= fi } diff --git a/plugins/config-getvar.in b/plugins/config-getvar.in index 434faa9..c747f3c 100644 --- a/plugins/config-getvar.in +++ b/plugins/config-getvar.in @@ -13,8 +13,6 @@ me=(${0##*/} "@version@" "@date@") . @libdir@/libmsgmng.lib # default values: -# - colorized output (disabled by default) -let "colorize = 0" # - output verbosity let "verbose = 1" @@ -63,8 +61,7 @@ function usage() { -h, --help "$"Print this help, then exit"" -V, --version "$"Print version number, then exit"" -q, --quiet "$"Run in quiet mode"" - -r, --colorize "$"Enable the colorized output"" - --colorize-theme "$"Select the theme to be used for the colorized output"" + --colors "$"Select the theme to be used for the colorized output"" -D, --debug "$"Run in debugging mode (very verbose output)"" "$"Samples"": @@ -97,7 +94,7 @@ done exec_options=`LC_ALL=C getopt \ -o C:DqrhV \ --long eval:,config:,\ -debug,quiet,colorize,colorize-theme:,help,version,\ +debug,quiet,colors:,help,version,\ frontend_opts: \ -n "$me" -- "$@"` [ $? = 0 ] || exit 1 @@ -115,11 +112,8 @@ while :; do let "verbose = 2" ;; -q|--quiet) let "verbose = 0" ;; - -r|--colorize) - let "colorize = 1" ;; - --colorize-theme) - colorize_theme="$2"; shift - let "colorize = 1" ;; + --colors) + color_scheme="$2"; shift ;; -h|--help) usage 0 ;; -V|--version) @@ -135,8 +129,7 @@ for arg in $@; do notify.error $"unrecognized option"" -- \`$arg'" done -[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ - || notify.disable_colors +notify.enable_colors "$color_scheme" # config.getvar() # Parameters: diff --git a/plugins/pck-extract.in b/plugins/pck-extract.in index 5e1d34b..61592cb 100644 --- a/plugins/pck-extract.in +++ b/plugins/pck-extract.in @@ -13,8 +13,6 @@ me=(${0##*/} "@version@" "@date@") . @libdir@/libmsgmng.lib # default values: -# - colorized output (disabled by default) -let "colorize = 0" # - output verbosity let "verbose = 1" @@ -67,8 +65,7 @@ function usage() { -h, --help "$"Print this help, then exit"" -V, --version "$"Print version number, then exit"" -q, --quiet "$"Run in quiet mode"" - -r, --colorize "$"Enable the colorized output"" - --colorize-theme "$"Select the theme to be used for the colorized output"" + --colors "$"Select the theme to be used for the colorized output"" -D, --debug "$"Run in debugging mode (very verbose output)"" "$"Samples"": @@ -102,7 +99,7 @@ exec_options=`LC_ALL=C getopt \ -o xF:DqrhV \ --long \ extract,files:,destdir:,\ -debug,quiet,colorize,colorize-theme:,help,version,\ +debug,quiet,colors:,help,version,\ frontend_opts: \ -n "$me" -- "$@"` [ $? = 0 ] || exit 1 @@ -121,11 +118,8 @@ while :; do let "verbose = 2" ;; -q|--quiet) let "verbose = 0" ;; - -r|--colorize) - let "colorize = 1" ;; - --colorize-theme) - colorize_theme="$2"; shift - let "colorize = 1" ;; + --colors) + color_scheme="$2"; shift ;; -h|--help) usage 0 ;; -V|--version) @@ -141,8 +135,7 @@ for arg in $@; do notify.error $"unrecognized option"" -- \`$arg'" done -[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ - || notify.disable_colors +notify.enable_colors "$color_scheme" # s_rpm_pck : the name of the srpm package (local or remote) # (i.e. /usr/src/RPM/SRPMS/automake-1.9-1qilnx.src.rpm) diff --git a/plugins/pck-update.in b/plugins/pck-update.in index 1ef58f4..432f621 100644 --- a/plugins/pck-update.in +++ b/plugins/pck-update.in @@ -31,8 +31,6 @@ me=(${0##*/} "@version@" "@date@") . @libdir@/libapse.lib # default values: -# colorized output (disabled by default) -let "colorize = 0" # output verbosity let "verbose = 1" # @@ -153,8 +151,7 @@ function usage() { -h, --help "$"Print this help, then exit"" -V, --version "$"Print version number, then exit"" -q, --quiet "$"Run in quiet mode"" - -r, --colorize "$"Enable the colorized output"" - --colorize-theme "$"Select the theme to be used for the colorized output"" + --colors "$"Select the theme to be used for the colorized output"" -D, --debug "$"Run in debugging mode (very verbose output)"" "$"Samples"": @@ -197,7 +194,7 @@ server-download:,server-upload:,server:,\ changelog:,nosrpm,norpm,list-check,update-autobuildreq,\ force-update,force-build,force-install,force-download,force,\ ignore-test:,clear,format,log,rebuild,root:,\ -debug,quiet,colorize,colorize-theme:,help,version,\ +debug,quiet,colors:,help,version,\ frontend_opts: \ -n "$me" -- "$@"` [ $? = 0 ] || exit 1 @@ -277,11 +274,8 @@ while :; do let "verbose = 2" ;; -q|--quiet) let "verbose = 0" ;; - -r|--colorize) - let "colorize = 1" ;; - --colorize-theme) - colorize_theme="$2"; shift - let "colorize = 1" ;; + --colors) + color_scheme="$2"; shift ;; -h|--help) usage 0 ;; -V|--version) @@ -312,10 +306,8 @@ if [ -n "$rpm_rootdir" ]; then notify.error $"no such file or directory"": $rpm_rootdir" fi -[ "$logging" = "1" ] && let "colorize = 0" - -[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ - || notify.disable_colors +[ "$logging" = "1" ] && color_scheme="none" +notify.enable_colors "$color_scheme" # default values for non mandatory configuration variables [ "$logging_dir" ] || logging_dir="${tmppath_dir:-/var/tmp}/@package@" diff --git a/plugins/spec-create.in b/plugins/spec-create.in index 7729756..0ba19f4 100644 --- a/plugins/spec-create.in +++ b/plugins/spec-create.in @@ -18,8 +18,6 @@ me=(${0##*/} "@version@" "@date@") . @libdir@/libnetwork.lib # set default variables -# colorized output (disabled by default) -let "colorize = 0" # output verbosity let "verbose = 1" @@ -120,8 +118,7 @@ function usage() { -h, --help "$"Print this help, then exit"" -V, --version "$"Print version number, then exit"" -q, --quiet "$"Run in quiet mode"" - -r, --colorize "$"Enable the colorized output"" - --colorize-theme "$"Select the theme to be used for the colorized output"" + --colors "$"Select the theme to be used for the colorized output"" -D, --debug "$"Run in debugging mode (very verbose output)"" "$"Samples"": @@ -163,7 +160,7 @@ exec_options=`LC_ALL=C getopt \ --long \ source:,pck-name:,pck-version:,type:,output:,changelog:,\ git-branch:,preserve-dot-git,\ -debug,quiet,colorize,colorize-theme:,help,version,\ +debug,quiet,colors:,help,version,\ frontend_opts: \ -n "$me" -- "$@"` [ $? = 0 ] || exit 1 @@ -196,11 +193,8 @@ while :; do let "verbose = 2" ;; -q|--quiet) let "verbose = 0" ;; - -r|--colorize) - let "colorize = 1" ;; - --colorize-theme) - colorize_theme="$2"; shift - let "colorize = 1" ;; + --colors) + color_scheme="$2"; shift ;; -h|--help) usage 0 ;; -V|--version) @@ -211,8 +205,7 @@ while :; do shift done -[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \ - || notify.disable_colors +notify.enable_colors "$color_scheme" for arg in $@; do notify.error $"unrecognized option"" -- \`$arg'" diff --git a/po/it/autospec_fe.po b/po/it/autospec_fe.po index 2ed807f..7f06fd5 100644 --- a/po/it/autospec_fe.po +++ b/po/it/autospec_fe.po @@ -55,9 +55,6 @@ msgstr "Stampa il numero di versione e termina il programma" msgid "Run in quiet mode" 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" msgstr "Seleziona il tema da usare per generare l'output colorato" @@ -79,8 +76,8 @@ msgstr "libreria non trovata" msgid "deprecated option" msgstr "opzione deprecata" -msgid "use \\`--colorize-theme' instead" -msgstr "utilizzare invece \\`--colorize-theme'" +msgid "use \\`--colors' instead" +msgstr "utilizzare \\`--colors'" msgid "version" msgstr "versione" diff --git a/po/it/config-getvar.po b/po/it/config-getvar.po index 3fb904c..fef08d1 100644 --- a/po/it/config-getvar.po +++ b/po/it/config-getvar.po @@ -66,9 +66,6 @@ msgstr "Stampa il numero di versione e termina il programma" msgid "Run in quiet mode" 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" msgstr "Seleziona il tema da usare per generare l'output colorato" diff --git a/po/it/libmsgmng.po b/po/it/libmsgmng.po index 21ddea5..c1de4c7 100644 --- a/po/it/libmsgmng.po +++ b/po/it/libmsgmng.po @@ -22,5 +22,6 @@ msgstr "questo script richiede bash versione 2 o superiore" msgid "no message" msgstr "nessun messaggio" -msgid "unknown color theme \\`$colorize_theme': colors will be disabled" -msgstr "tema di colori sconosciuto \\`$colorize_theme': output con colori disabilitato" +msgid "unknown color theme \\`$color_scheme': colors will be disabled" +msgstr "tema di colori sconosciuto \\`$color_scheme': output con colori disabilitato" + diff --git a/po/it/pck-extract.po b/po/it/pck-extract.po index 4f60684..dcbc95a 100644 --- a/po/it/pck-extract.po +++ b/po/it/pck-extract.po @@ -63,9 +63,6 @@ msgstr "Stampa il numero di versione e termina il programma" msgid "Run in quiet mode" 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" msgstr "Seleziona il tema da usare per generare l'output colorato" diff --git a/po/it/pck-update.po b/po/it/pck-update.po index 1f49b14..f78395c 100644 --- a/po/it/pck-update.po +++ b/po/it/pck-update.po @@ -180,9 +180,6 @@ msgstr "Stampa il numero di versione e termina il programma" msgid "Run in quiet mode" 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" msgstr "Seleziona il tema da usare per generare l'output colorato" diff --git a/po/it/spec-create.po b/po/it/spec-create.po index 2343ea2..73bb4c5 100644 --- a/po/it/spec-create.po +++ b/po/it/spec-create.po @@ -100,9 +100,6 @@ msgstr "Stampa il numero di versione e termina il programma" msgid "Run in quiet mode" 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" msgstr "Seleziona il tema da usare per generare l'output colorato"