|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# cli_printActionPreamble -- This function standardizes the way
|
|
|
878a2b |
|
|
|
878a2b |
# actions (e.g., file elimination, edition, creation, actualization,
|
|
|
878a2b |
|
|
|
878a2b |
# is performed or not.
|
|
|
878a2b |
#
|
|
|
878a2b |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
#
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function cli_printActionPreamble {
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local ARGSS=''
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local ARGSL='to-create,to-delete,to-locale,to-edit'
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local ARGUMENTS=''
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local MESSAGE=''
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local OPTION=''
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local FILE=''
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
cli_parseArgumentsReDef "$@"
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
cli_parseArguments
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
eval set -- "$ARGUMENTS"
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!')
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local COUNT=$(echo $FILES | wc -l)
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
while true;do
|
|
|
878a2b |
|
|
|
878a2b |
case "$1" in
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ $FILES == '--' ]];then
|
|
|
878a2b |
MESSAGE="`gettext "There is no entry to create."`"
|
|
|
878a2b |
OPTION='--as-error-line'
|
|
|
878a2b |
else
|
|
|
878a2b |
MESSAGE="`ngettext "The following entry will be created" \
|
|
|
878a2b |
"The following entries will be created" $COUNT`:"
|
|
|
878a2b |
OPTION=''
|
|
|
878a2b |
fi
|
|
|
878a2b |
shift 2
|
|
|
878a2b |
break
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
--to-delete )
|
|
|
878a2b |
if [[ $FILES == '--' ]];then
|
|
|
878a2b |
MESSAGE="`gettext "There is no file to delete."`"
|
|
|
878a2b |
OPTION='--as-error-line'
|
|
|
878a2b |
else
|
|
|
878a2b |
MESSAGE="`ngettext "The following entry will be deleted" \
|
|
|
878a2b |
"The following entries will be deleted" $COUNT`:"
|
|
|
878a2b |
OPTION=''
|
|
|
878a2b |
fi
|
|
|
878a2b |
shift 2
|
|
|
878a2b |
break
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ $FILES == '--' ]];then
|
|
|
878a2b |
MESSAGE="`gettext "There is no file to locale."`"
|
|
|
878a2b |
OPTION='--as-error-line'
|
|
|
878a2b |
else
|
|
|
878a2b |
MESSAGE="`ngettext "Translatable strings will be retrived from the following entry" \
|
|
|
878a2b |
"Translatable strings will be retrived from the following entries" $COUNT`:"
|
|
|
878a2b |
OPTION=''
|
|
|
878a2b |
fi
|
|
|
878a2b |
shift 2
|
|
|
878a2b |
break
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ $FILES == '--' ]];then
|
|
|
878a2b |
MESSAGE="`gettext "There is no file to edit."`"
|
|
|
878a2b |
OPTION='--as-error-line'
|
|
|
878a2b |
else
|
|
|
878a2b |
MESSAGE="`ngettext "The following file will be edited" \
|
|
|
878a2b |
"The following files will be edited" $COUNT`:"
|
|
|
878a2b |
OPTION=''
|
|
|
878a2b |
fi
|
|
|
878a2b |
shift 2
|
|
|
878a2b |
break
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ $FILES == '--' ]];then
|
|
|
878a2b |
MESSAGE="`gettext "There is no file to process."`"
|
|
|
878a2b |
OPTION='--as-error-line'
|
|
|
878a2b |
else
|
|
|
878a2b |
MESSAGE="`ngettext "The following file will be processed" \
|
|
|
878a2b |
"The following files will be processed" $COUNT`:"
|
|
|
878a2b |
OPTION=''
|
|
|
878a2b |
fi
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
|
|
|
878a2b |
esac
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
cli_printMessage "${MESSAGE}" "${OPTION}"
|
|
|
878a2b |
for FILE in $FILES;do
|
|
|
878a2b |
cli_printMessage "$FILE" --as-response-line
|
|
|
878a2b |
done
|
|
|
878a2b |
cli_printMessage "`gettext "Do you want to continue"`" --as-yesornorequest-line
|
|
|
878a2b |
|
|
|
878a2b |
}
|