|
|
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 |
|
|
|
0cb4af |
local DIR=''
|
|
|
0cb4af |
local DIRS=''
|
|
|
0cb4af |
local PARENT="$1"
|
|
|
0cb4af |
local ACTION="$2"
|
|
|
0cb4af |
local FORMAT="$3"
|
|
|
0cb4af |
local COUNT_DIRS=0
|
|
|
0cb4af |
|
|
|
a07e81 |
# Redefine directories using both parent and parallel directories
|
|
|
a07e81 |
# if PARENT path is only inside trunk/Identity structure.
|
|
|
a07e81 |
# Otherwise do not resolve parallel directories just parent ones.
|
|
|
a07e81 |
# This make possible to reuse cli_printActionPreamble in
|
|
|
a07e81 |
# functionalities that act on non-parent directory structures like
|
|
|
a07e81 |
# documentation (trunk/Manuals).
|
|
|
a07e81 |
if [[ $PARENT =~ "^$(cli_getRepoTLDir ${PARENT})/Identity/.+$" ]];then
|
|
|
a07e81 |
for DIR in $(echo $PARENT);do
|
|
|
a07e81 |
DIRS="$DIRS $DIR $(cli_getRepoParallelDirs $DIR)"
|
|
|
a07e81 |
done
|
|
|
a07e81 |
else
|
|
|
a07e81 |
for DIR in $(echo $PARENT);do
|
|
|
a07e81 |
DIRS="$DIRS $DIR"
|
|
|
a07e81 |
done
|
|
|
a07e81 |
fi
|
|
|
0cb4af |
|
|
|
a07e81 |
# Redefine total number of directories.
|
|
|
a07e81 |
COUNT_DIRS=$(echo "$DIRS" | sed -r "s! +!\n!g" | wc -l)
|
|
|
0cb4af |
|
|
|
0cb4af |
# Redefine preamble messages based on action.
|
|
|
0cb4af |
case $ACTION in
|
|
|
0cb4af |
'doCreate' )
|
|
|
0cb4af |
ACTION="`ngettext "The following entry will be created" \
|
|
|
0cb4af |
"The following entries will be created" $COUNT_DIRS`:"
|
|
|
0cb4af |
;;
|
|
|
0cb4af |
|
|
|
0cb4af |
'doDelete' )
|
|
|
0cb4af |
ACTION="`ngettext "The following entry will be deleted" \
|
|
|
0cb4af |
"The following entries will be deleted" $COUNT_DIRS`:"
|
|
|
0cb4af |
;;
|
|
|
0cb4af |
|
|
|
0cb4af |
* )
|
|
|
0cb4af |
cli_printMessage "cli_printActionPreamble: `gettext "The second argument is not valid."`" 'AsErrorLine'
|
|
|
0cb4af |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
0cb4af |
;;
|
|
|
0cb4af |
esac
|
|
|
0cb4af |
|
|
|
0cb4af |
# Print preamble message.
|
|
|
0cb4af |
cli_printMessage "$ACTION"
|
|
|
0cb4af |
for DIR in $(echo $DIRS);do
|
|
|
0cb4af |
cli_printMessage "$DIR" "$FORMAT"
|
|
|
0cb4af |
done
|
|
|
0cb4af |
cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine'
|
|
|
0cb4af |
|
|
|
0cb4af |
}
|