autospec,plugins,libraries: a color scheme can be selected now by using the new command-line option '--colorize-theme'
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
parent
990661c11e
commit
cd7d6b663d
@ -13,6 +13,11 @@ Changes in version 1.14.2
|
||||
* autospec - Davide Madrisan:
|
||||
Send the debug message showing autospec version as soon as possible.
|
||||
|
||||
+ improvement
|
||||
* autospec, plugins/*,lib/lib*.lib - Davide Madrisan:
|
||||
A color scheme can be selected now by using the new command-line option
|
||||
'--colorize-theme'.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes in version 1.14.1 - _TO*Hacklab release
|
||||
|
35
autospec.in
35
autospec.in
@ -63,6 +63,7 @@ function autospec.usage() {
|
||||
-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""
|
||||
-D, --debug "$"Run in debugging mode (very verbose output)""
|
||||
|
||||
"$"Usage"":
|
||||
@ -90,8 +91,29 @@ notify.disable_colors
|
||||
{ echo "$me: "$"library not found"": @libdir@/libcfg.lib" 1>&2
|
||||
exit 1; }
|
||||
|
||||
for arg in $@; do
|
||||
case $arg in
|
||||
# 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.
|
||||
# see. /usr/sbin/mkinitrd (dracut-024)
|
||||
function read_arg() {
|
||||
# $1 = arg name
|
||||
# $2 = arg value
|
||||
# $3 = arg parameter
|
||||
local rematch='^[^=]*=(.*)$'
|
||||
if [[ $2 =~ $rematch ]]; then
|
||||
read "$1" <<< "${BASH_REMATCH[1]}"
|
||||
elif [[ $3 != -* ]]; then
|
||||
# Only read next arg if it not an arg itself.
|
||||
read "$1" <<< "$3"
|
||||
# There is no way to shift our callers args, so
|
||||
# return 1 to indicate they should do it instead.
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
args=($@)
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
-u|--update)
|
||||
let "pck_update = 1" ;;
|
||||
-s|--source)
|
||||
@ -106,15 +128,19 @@ for arg in $@; do
|
||||
let "verbose = 0" ;;
|
||||
-r|--colorize)
|
||||
let "colorize = 1" ;;
|
||||
--colorize-theme)
|
||||
read_arg colorize_theme "$@" || shift ;;
|
||||
-h|--help)
|
||||
let "print_help = 1" ;;
|
||||
-V|--version)
|
||||
let "print_version = 1" ;;
|
||||
*) ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
notify.debug "[${me[0]}, "$"version"" ${me[1]}]"
|
||||
notify.debug "colorize_theme = \"$colorize_theme\""
|
||||
|
||||
case "$(( $pck_update + $spec_create + $pck_extract + $config_getvar ))" in
|
||||
0) [ "$print_help" = "1" ] && autospec.usage 0
|
||||
@ -157,9 +183,8 @@ notify.debug "tmpargfile = \`${NOTE}$tmpargfile${NORM}'"
|
||||
# workaround to bypass the issues related to bash expansion in multi-word
|
||||
# strings (ex: autospec -u s.spec -a4 1.0 --changelog "here's the problem")
|
||||
echo -n "set -- " > $tmpargfile
|
||||
while [ $# -gt 0 ]; do
|
||||
echo -n "\"$1\" " >> $tmpargfile
|
||||
shift
|
||||
for i in `seq 1 1 ${#args[@]}`; do
|
||||
echo -n "\"${args[$i-1]}\" " >> $tmpargfile
|
||||
done
|
||||
echo >> $tmpargfile
|
||||
|
||||
|
@ -14,31 +14,6 @@ if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then
|
||||
fi
|
||||
TEXTDOMAIN="libmsgmng"; export TEXTDOMAIN
|
||||
|
||||
# function notify.enable_colors
|
||||
# enable if possible the colorized output
|
||||
# args:
|
||||
# none
|
||||
function notify.enable_colors() {
|
||||
if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then
|
||||
ESC=$(echo -en "\033") # ascii ESCape
|
||||
[ "$CRIT" ] || CRIT="${ESC}[1;31m" # switch on red
|
||||
[ "$NOTE" ] || NOTE="${ESC}[1;33m" # switch on yellow
|
||||
[ "$WARN" ] || WARN="${ESC}[1;31m"
|
||||
[ "$EXIT" ] || EXIT="${ESC}[1;31m"
|
||||
[ "$NORM" ] || NORM=$(echo -en "${ESC}[m\017")
|
||||
else
|
||||
ESC= CRIT= NOTE= WARN= EXIT= NORM=
|
||||
fi
|
||||
}
|
||||
|
||||
# function notify.disable_colors
|
||||
# disable the colorized output
|
||||
# args:
|
||||
# none
|
||||
function notify.disable_colors() {
|
||||
ESC= CRIT= NOTE= WARN= EXIT= NORM=
|
||||
}
|
||||
|
||||
# notify family of message handling functions:
|
||||
# - notify.warning
|
||||
# - notify.error
|
||||
@ -73,4 +48,59 @@ function notify.note() {
|
||||
echo -e "${1:-$notify_def_msg}"
|
||||
}
|
||||
|
||||
# function notify.enable_colors
|
||||
# enable if possible the colorized output
|
||||
# args:
|
||||
# none
|
||||
function notify.enable_colors() {
|
||||
local colorize_theme="$1"
|
||||
# for backward compatibility
|
||||
[ "$colorize_theme" ] || colorize_theme="terminal-dark"
|
||||
|
||||
case "$colorize_theme" in
|
||||
"web")
|
||||
CRIT="<font color=white style=\"background-color:red\">"
|
||||
NOTE="<font color=gold>"
|
||||
WARN="<font color=red>"
|
||||
EXIT="$CRIT"
|
||||
NORM="</font>"
|
||||
;;
|
||||
"terminal-white")
|
||||
if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then
|
||||
ESC=$(echo -en "\033") # ascii ESCape
|
||||
[ "$NOTE" ] || NOTE="${ESC}[1;34m" # switch on blu
|
||||
[ "$WARN" ] || WARN="${ESC}[1;31m"
|
||||
[ "$EXIT" ] || EXIT="${ESC}[1;31m"
|
||||
[ "$NORM" ] || NORM=$(echo -en "${ESC}[m\017")
|
||||
else
|
||||
ESC= CRIT= NOTE= WARN= EXIT= NORM=
|
||||
fi
|
||||
;;
|
||||
"terminal-dark")
|
||||
if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then
|
||||
ESC=$(echo -en "\033") # ascii ESCape
|
||||
[ "$CRIT" ] || CRIT="${ESC}[1;31m" # switch on red
|
||||
[ "$NOTE" ] || NOTE="${ESC}[1;33m" # switch on yellow
|
||||
[ "$WARN" ] || WARN="${ESC}[1;31m"
|
||||
[ "$EXIT" ] || EXIT="${ESC}[1;31m"
|
||||
[ "$NORM" ] || NORM=$(echo -en "${ESC}[m\017")
|
||||
else
|
||||
ESC= CRIT= NOTE= WARN= EXIT= NORM=
|
||||
fi
|
||||
;;
|
||||
*) echo \
|
||||
$"unknown color theme \`$colorize_theme': colors will be disabled"
|
||||
ESC= CRIT= NOTE= WARN= EXIT= NORM=
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# function notify.disable_colors
|
||||
# disable the colorized output
|
||||
# args:
|
||||
# none
|
||||
function notify.disable_colors() {
|
||||
ESC= CRIT= NOTE= WARN= EXIT= NORM=
|
||||
}
|
||||
|
||||
} # endif $libmsgmng_is_loaded
|
||||
|
@ -64,6 +64,7 @@ function usage() {
|
||||
-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""
|
||||
-D, --debug "$"Run in debugging mode (very verbose output)""
|
||||
|
||||
"$"Samples"":
|
||||
@ -96,7 +97,7 @@ done
|
||||
exec_options=`LC_ALL=C getopt \
|
||||
-o C:DqrhV \
|
||||
--long eval:,config:,\
|
||||
debug,quiet,colorize,help,version,\
|
||||
debug,quiet,colorize,colorize-theme:,help,version,\
|
||||
frontend_opts: \
|
||||
-n "$me" -- "$@"`
|
||||
[ $? = 0 ] || exit 1
|
||||
@ -116,6 +117,8 @@ while :; do
|
||||
let "verbose = 0" ;;
|
||||
-r|--colorize)
|
||||
let "colorize = 1" ;;
|
||||
--colorize-theme)
|
||||
colorize_theme="$2"; shift ;;
|
||||
-h|--help)
|
||||
usage 0 ;;
|
||||
-V|--version)
|
||||
@ -131,7 +134,8 @@ for arg in $@; do
|
||||
notify.error $"unrecognized option"" -- \`$arg'"
|
||||
done
|
||||
|
||||
[ "$colorize" = "1" ] && notify.enable_colors || notify.disable_colors
|
||||
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \
|
||||
|| notify.disable_colors
|
||||
|
||||
# config.getvar()
|
||||
# Parameters:
|
||||
|
@ -68,6 +68,7 @@ function usage() {
|
||||
-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""
|
||||
-D, --debug "$"Run in debugging mode (very verbose output)""
|
||||
|
||||
"$"Samples"":
|
||||
@ -101,7 +102,7 @@ exec_options=`LC_ALL=C getopt \
|
||||
-o xF:DqrhV \
|
||||
--long \
|
||||
extract,files:,destdir:,\
|
||||
debug,quiet,colorize,help,version,\
|
||||
debug,quiet,colorize,colorize-theme:,help,version,\
|
||||
frontend_opts: \
|
||||
-n "$me" -- "$@"`
|
||||
[ $? = 0 ] || exit 1
|
||||
@ -122,6 +123,8 @@ while :; do
|
||||
let "verbose = 0" ;;
|
||||
-r|--colorize)
|
||||
let "colorize = 1" ;;
|
||||
--colorize-theme)
|
||||
colorize_theme="$2"; shift ;;
|
||||
-h|--help)
|
||||
usage 0 ;;
|
||||
-V|--version)
|
||||
@ -137,7 +140,8 @@ for arg in $@; do
|
||||
notify.error $"unrecognized option"" -- \`$arg'"
|
||||
done
|
||||
|
||||
[ "$colorize" = "1" ] && notify.enable_colors || notify.disable_colors
|
||||
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \
|
||||
|| notify.disable_colors
|
||||
|
||||
# s_rpm_pck : the name of the srpm package (local or remote)
|
||||
# (i.e. /usr/src/RPM/SRPMS/automake-1.9-1qilnx.src.rpm)
|
||||
|
@ -154,6 +154,7 @@ function usage() {
|
||||
-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""
|
||||
-D, --debug "$"Run in debugging mode (very verbose output)""
|
||||
|
||||
"$"Samples"":
|
||||
@ -196,7 +197,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,help,version,\
|
||||
debug,quiet,colorize,colorize-theme:,help,version,\
|
||||
frontend_opts: \
|
||||
-n "$me" -- "$@"`
|
||||
[ $? = 0 ] || exit 1
|
||||
@ -278,6 +279,8 @@ while :; do
|
||||
let "verbose = 0" ;;
|
||||
-r|--colorize)
|
||||
let "colorize = 1" ;;
|
||||
--colorize-theme)
|
||||
colorize_theme="$2"; shift ;;
|
||||
-h|--help)
|
||||
usage 0 ;;
|
||||
-V|--version)
|
||||
@ -310,7 +313,9 @@ fi
|
||||
|
||||
[ "$logging" = "1" ] && let "colorize = 0"
|
||||
|
||||
[ "$colorize" = "1" ] && notify.enable_colors || notify.disable_colors
|
||||
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \
|
||||
|| notify.disable_colors
|
||||
|
||||
# default values for non mandatory configuration variables
|
||||
[ "$logging_dir" ] || logging_dir="${tmppath_dir:-/var/tmp}/@package@"
|
||||
|
||||
|
@ -121,6 +121,7 @@ function usage() {
|
||||
-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""
|
||||
-D, --debug "$"Run in debugging mode (very verbose output)""
|
||||
|
||||
"$"Samples"":
|
||||
@ -162,7 +163,7 @@ exec_options=`LC_ALL=C getopt \
|
||||
--long \
|
||||
source:,pck-name:,pck-version:,type:,output:,changelog:,\
|
||||
git-branch:,preserve-dot-git,\
|
||||
debug,quiet,colorize,help,version,\
|
||||
debug,quiet,colorize,colorize-theme:,help,version,\
|
||||
frontend_opts: \
|
||||
-n "$me" -- "$@"`
|
||||
[ $? = 0 ] || exit 1
|
||||
@ -197,6 +198,8 @@ while :; do
|
||||
let "verbose = 0" ;;
|
||||
-r|--colorize)
|
||||
let "colorize = 1" ;;
|
||||
--colorize-theme)
|
||||
colorize_theme="$2"; shift ;;
|
||||
-h|--help)
|
||||
usage 0 ;;
|
||||
-V|--version)
|
||||
@ -207,7 +210,8 @@ while :; do
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$colorize" = "1" ] && notify.enable_colors || notify.disable_colors
|
||||
[ "$colorize" = "1" ] && notify.enable_colors "$colorize_theme" \
|
||||
|| notify.disable_colors
|
||||
|
||||
for arg in $@; do
|
||||
notify.error $"unrecognized option"" -- \`$arg'"
|
||||
|
@ -58,6 +58,9 @@ 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"
|
||||
|
||||
msgid "Run in debugging mode (very verbose output)"
|
||||
msgstr "Attiva la modalità di debugging (output prolisso)"
|
||||
|
||||
|
@ -69,6 +69,9 @@ 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"
|
||||
|
||||
msgid "Run in debugging mode (very verbose output)"
|
||||
msgstr "Attiva la modalità di debugging (output prolisso)"
|
||||
|
||||
|
@ -21,3 +21,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"
|
||||
|
@ -66,6 +66,9 @@ 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"
|
||||
|
||||
msgid "Run in debugging mode (very verbose output)"
|
||||
msgstr "Attiva la modalità di debugging (output prolisso)"
|
||||
|
||||
|
@ -183,6 +183,9 @@ 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"
|
||||
|
||||
msgid "Run in debugging mode (very verbose output)"
|
||||
msgstr "Attiva la modalità di debugging (output prolisso)"
|
||||
|
||||
|
@ -103,6 +103,9 @@ 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"
|
||||
|
||||
msgid "Run in debugging mode (very verbose output)"
|
||||
msgstr "Attiva la modalità di debugging (output prolisso)"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user