Blame Scripts/Functions/Html/html_getActions.sh

9f1608
#!/bin/bash
9f1608
#
1a9d63
# html_getActions.sh -- This function interprets arguments passed to
1a9d63
# `html' functionality and calls actions accordingly.
9f1608
#
9f5f2e
# Copyright (C) 2009-2011 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.
d01236
    local ARGSS=""
9f1608
1a9d63
    # Define long options we want to support.
d01236
    local ARGSL="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
                # Define action name using action value as reference.
1a9d63
                ACTIONNAM="${FUNCNAM}_updateHeadings"
1a9d63
d01236
                # Rotate positional parameters.
d01236
                shift 2
1a9d63
                ;;
1a9d63
1a9d63
            * )
1a9d63
                break
1a9d63
        esac
1a9d63
    done
1a9d63
d01236
    # Check action value. Be sure the action value matches the
d01236
    # convenctions defined for source locations inside the working
d01236
    # copy.
d01236
    cli_checkRepoDirSource
282759
d01236
    # Syncronize changes between the working copy and the central
d01236
    # repository to bring down changes.
f54510
    cli_syncroRepoChanges
282759
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
d01236
    # Syncronize changes between the working copy and the central
d01236
    # repository to commit up changes.
ec5968
    cli_commitRepoChanges
d01236
9f1608
}