|
|
9f1608 |
#!/bin/bash
|
|
|
9f1608 |
#
|
|
|
1a9d63 |
# html_getActions.sh -- This function interprets arguments passed to
|
|
|
1a9d63 |
# `html' functionality and calls actions accordingly.
|
|
|
9f1608 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
9f1608 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
9f1608 |
#
|
|
|
9f1608 |
# This program is distributed in the hope that it will be useful, but
|
|
|
9f1608 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9f1608 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
9f1608 |
# General Public License for more details.
|
|
|
9f1608 |
#
|
|
|
9f1608 |
# You should have received a copy of the GNU General Public License
|
|
|
9f1608 |
# along with this program; if not, write to the Free Software
|
|
|
9f1608 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
9f1608 |
# USA.
|
|
|
9f1608 |
#
|
|
|
9f1608 |
# ----------------------------------------------------------------------
|
|
|
9f1608 |
# $Id$
|
|
|
9f1608 |
# ----------------------------------------------------------------------
|
|
|
9f1608 |
|
|
|
9f1608 |
function html_getActions {
|
|
|
9f1608 |
|
|
|
1a9d63 |
# Define short options we want to support.
|
|
|
1a9d63 |
local ARGSS="f:"
|
|
|
9f1608 |
|
|
|
1a9d63 |
# Define long options we want to support.
|
|
|
1a9d63 |
local ARGSL="filter:,update-headings:"
|
|
|
9f1608 |
|
|
|
1a9d63 |
# Parse arguments using getopt(1) command parser.
|
|
|
1a9d63 |
cli_doParseArguments
|
|
|
ffdd74 |
|
|
|
1a9d63 |
# Reset positional parameters using output from (getopt) argument
|
|
|
1a9d63 |
# parser.
|
|
|
1a9d63 |
eval set -- "$ARGUMENTS"
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Define action to take for each option passed.
|
|
|
1a9d63 |
while true; do
|
|
|
1a9d63 |
case "$1" in
|
|
|
1a9d63 |
|
|
|
1a9d63 |
--update-headings )
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Define action value passed through the command-line.
|
|
|
1a9d63 |
ACTIONVAL="$2"
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Check action value passed through the command-line.
|
|
|
1a9d63 |
cli_checkRepoDirSource
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Define action name using action value as reference.
|
|
|
1a9d63 |
ACTIONNAM="${FUNCNAM}_updateHeadings"
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Look for sub-options passed through command-line.
|
|
|
1a9d63 |
while true; do
|
|
|
1a9d63 |
case "$3" in
|
|
|
1a9d63 |
-f|--filter )
|
|
|
1a9d63 |
# Redefine regular expression.
|
|
|
1a9d63 |
REGEX="$4"
|
|
|
1a9d63 |
# Rotate positional parameters
|
|
|
1a9d63 |
shift 4
|
|
|
1a9d63 |
;;
|
|
|
1a9d63 |
* )
|
|
|
1a9d63 |
# Break sub-options loop.
|
|
|
1a9d63 |
break
|
|
|
1a9d63 |
;;
|
|
|
1a9d63 |
esac
|
|
|
1a9d63 |
done
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Break options loop.
|
|
|
1a9d63 |
break
|
|
|
1a9d63 |
;;
|
|
|
1a9d63 |
|
|
|
1a9d63 |
* )
|
|
|
1a9d63 |
break
|
|
|
1a9d63 |
esac
|
|
|
1a9d63 |
done
|
|
|
1a9d63 |
|
|
|
1a9d63 |
# Verify action value variable.
|
|
|
1a9d63 |
if [[ $ACTIONVAL == '' ]];then
|
|
|
1a9d63 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
1a9d63 |
fi
|
|
|
9f1608 |
|
|
|
1a9d63 |
# Execute action name.
|
|
|
1a9d63 |
if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
|
|
|
1a9d63 |
eval $ACTIONNAM
|
|
|
1a9d63 |
else
|
|
|
1a9d63 |
cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
|
|
|
1a9d63 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
1a9d63 |
fi
|
|
|
1a9d63 |
|
|
|
9f1608 |
}
|