|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# cli_printMessage.sh -- This function outputs information in
|
|
|
4c79b5 |
# predifined formats. This function (cli_printMessage) is the standard
|
|
|
4c79b5 |
# way to output information inside centos-art.sh script.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# cli_printMessage $1 $2
|
|
|
4c79b5 |
# $1 --> The message you want to output.
|
|
|
4c79b5 |
# $2 --> The message format.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is free software; you can redistribute it and/or modify
|
|
|
4c79b5 |
# it under the terms of the GNU General Public License as published by
|
|
|
4c79b5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
4c79b5 |
# (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
# $Id: cli_printMessage.sh 98 2010-09-19 16:01:53Z al $
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function cli_printMessage {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define variables as local to avoid conflicts outside.
|
|
|
4c79b5 |
local MESSAGE="$1"
|
|
|
4c79b5 |
local FORMAT="$2"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Reduce paths inside output messages. The main purpose for this
|
|
|
4c79b5 |
# is to free horizontal space in output messages.
|
|
|
841480 |
MESSAGE=$(echo "$MESSAGE" \
|
|
|
841480 |
| sed -r 's!/home/centos/artwork/(trunk|branches|tags)/!\1/!')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Remove blank spaces from lines' begining.
|
|
|
4c79b5 |
MESSAGE=$(echo "$MESSAGE" | sed -r 's!^[[:space:]]+!!')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define message formats.
|
|
|
4c79b5 |
case $FORMAT in
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsHeadingLine' )
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
echo "$MESSAGE" | fmt --width=70
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsWarningLine' )
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
echo "`gettext "WARNING"`: $MESSAGE" | fmt --width=70
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsNoteLine' )
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
echo "`gettext "NOTE"`: $MESSAGE" | fmt --width=70
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsHelpLine' )
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
echo "$MESSAGE" | fmt --width=70
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
cli_printMessage "`gettext "HELP"`: centos-art help --read=$OPTIONVAL"
|
|
|
4c79b5 |
echo '----------------------------------------------------------------------'
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsUpdatingLine' )
|
|
|
6253fc |
echo "`gettext "Updating"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsRemovingLine' )
|
|
|
6253fc |
echo "`gettext "Removing"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsCheckingLine' )
|
|
|
6253fc |
echo "`gettext "Checking"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsCreatingLine' )
|
|
|
6253fc |
echo "`gettext "Creating"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsSavedAsLine' )
|
|
|
6253fc |
echo "`gettext "Saved as"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsLinkToLine' )
|
|
|
6253fc |
echo "`gettext "Linked to"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
6253fc |
;;
|
|
|
6253fc |
|
|
|
6253fc |
'AsMovedToLine' )
|
|
|
6253fc |
echo "`gettext "Moved to"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsTranslationLine' )
|
|
|
6253fc |
echo "`gettext "Translation"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
e92b23 |
;;
|
|
|
e92b23 |
|
|
|
e92b23 |
'AsConfigurationLine' )
|
|
|
e92b23 |
echo "`gettext "Configuration"`: $MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsResponseLine' )
|
|
|
4c79b5 |
echo "--> $MESSAGE"
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsRequestLine' )
|
|
|
4c79b5 |
echo -n $MESSAGE
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsYesOrNoRequestLine' )
|
|
|
4c79b5 |
echo -n "$MESSAGE [${Y}/${N}]: "
|
|
|
4c79b5 |
read ANSWER
|
|
|
4c79b5 |
if [[ ! $ANSWER =~ "^${Y}" ]];then
|
|
|
4c79b5 |
exit
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'AsToKnowMoreLine' )
|
|
|
1f1b3c |
# This option receives the output of bash's caller builtin
|
|
|
1f1b3c |
# as message value, in order to produce the documentation
|
|
|
1f1b3c |
# entry automatically. As caller builtin outputs the
|
|
|
1f1b3c |
# caller file path, documentation entry built from here is
|
|
|
1f1b3c |
# a file documentation entry.
|
|
|
1f1b3c |
MESSAGE=$(echo $MESSAGE | cut -d ' ' -f2-)
|
|
|
1f1b3c |
MESSAGE="$(dirname $MESSAGE)' --filter='$(basename $MESSAGE)"
|
|
|
be93f6 |
echo "----------------------------------------------------------------------"
|
|
|
bcde3a |
echo "`gettext "To know more, run the following command"`:"
|
|
|
bcde3a |
echo "centos-art help --read='$MESSAGE'"
|
|
|
be93f6 |
echo "----------------------------------------------------------------------"
|
|
|
6253fc |
exit # <-- ATTENTION: Do not remove this line. We use this
|
|
|
6253fc |
# case as convenction to end script
|
|
|
6253fc |
# execution.
|
|
|
6253fc |
;;
|
|
|
6253fc |
|
|
|
6253fc |
'AsRegularLine' )
|
|
|
6253fc |
echo "$MESSAGE" \
|
|
|
e92b23 |
| awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
6253fc |
* )
|
|
|
4c79b5 |
echo "$MESSAGE"
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
esac
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|