|
|
0cb4af |
#!/bin/bash
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# cli_printActionPreamble -- This function standardizes action
|
|
|
0cb4af |
# preamble messages. Action preamble messages provides a confirmation
|
|
|
0cb4af |
# message that illustrate what files will be affected in the action.
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# Generally, actions are applied to parent directories. Each parent
|
|
|
0cb4af |
# directory has parallel directories associated. If one parent
|
|
|
0cb4af |
# directory is created/deleted, the parallel directories associated do
|
|
|
0cb4af |
# need to be created/deleted too.
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# This program is free software; you can redistribute it and/or
|
|
|
0cb4af |
# modify it under the terms of the GNU General Public License as
|
|
|
0cb4af |
# published by the Free Software Foundation; either version 2 of the
|
|
|
0cb4af |
# License, or (at your option) any later version.
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# This program is distributed in the hope that it will be useful, but
|
|
|
0cb4af |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
0cb4af |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
0cb4af |
# General Public License for more details.
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# You should have received a copy of the GNU General Public License
|
|
|
0cb4af |
# along with this program; if not, write to the Free Software
|
|
|
0cb4af |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
0cb4af |
# USA.
|
|
|
0cb4af |
#
|
|
|
0cb4af |
# ----------------------------------------------------------------------
|
|
|
0cb4af |
# $Id$
|
|
|
0cb4af |
# ----------------------------------------------------------------------
|
|
|
0cb4af |
|
|
|
0cb4af |
function cli_printActionPreamble {
|
|
|
0cb4af |
|
|
|
7b9a4d |
local FILE=''
|
|
|
7b9a4d |
local COUNT=0
|
|
|
98e44c |
local FILES="$1"
|
|
|
0cb4af |
local ACTION="$2"
|
|
|
0cb4af |
local FORMAT="$3"
|
|
|
98e44c |
|
|
|
a07e81 |
# Redefine total number of directories.
|
|
|
98e44c |
COUNT=$(echo "$FILES" | sed -r "s! +!\n!g" | wc -l)
|
|
|
0cb4af |
|
|
|
0cb4af |
# Redefine preamble messages based on action.
|
|
|
0cb4af |
case $ACTION in
|
|
|
ba231b |
|
|
|
0cb4af |
'doCreate' )
|
|
|
0cb4af |
ACTION="`ngettext "The following entry will be created" \
|
|
|
98e44c |
"The following entries will be created" $COUNT`:"
|
|
|
0cb4af |
;;
|
|
|
0cb4af |
|
|
|
0cb4af |
'doDelete' )
|
|
|
0cb4af |
ACTION="`ngettext "The following entry will be deleted" \
|
|
|
98e44c |
"The following entries will be deleted" $COUNT`:"
|
|
|
0cb4af |
;;
|
|
|
0cb4af |
|
|
|
6dc5d4 |
'doLocale' )
|
|
|
ba231b |
ACTION="`ngettext "Translatable strings will be retrived from the following entry" \
|
|
|
98e44c |
"Translatable strings will be retrived from the following entries" $COUNT`:"
|
|
|
6dc5d4 |
;;
|
|
|
6dc5d4 |
|
|
|
ba231b |
'doEdit' )
|
|
|
ba231b |
ACTION="`ngettext "The following file will be edited" \
|
|
|
98e44c |
"The following files will be edited" $COUNT`:"
|
|
|
ba231b |
;;
|
|
|
ba231b |
|
|
|
0cb4af |
esac
|
|
|
0cb4af |
|
|
|
0cb4af |
# Print preamble message.
|
|
|
0cb4af |
cli_printMessage "$ACTION"
|
|
|
98e44c |
for FILE in $FILES;do
|
|
|
98e44c |
cli_printMessage "$FILE" "$FORMAT"
|
|
|
0cb4af |
done
|
|
|
0cb4af |
cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine'
|
|
|
0cb4af |
|
|
|
0cb4af |
}
|