Blame Scripts/Bash/Functions/Svn/svn_getOptions.sh

384602
#!/bin/bash
384602
#
384602
# svn_getOptions.sh -- This function interprets option parameters
384602
# passed to `svn' functionality and calls actions accordingly.
384602
#
384602
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
384602
#
384602
# This program is free software; you can redistribute it and/or modify
384602
# it under the terms of the GNU General Public License as published by
384602
# the Free Software Foundation; either version 2 of the License, or (at
384602
# your option) any later version.
384602
#
384602
# This program is distributed in the hope that it will be useful, but
384602
# WITHOUT ANY WARRANTY; without even the implied warranty of
384602
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
384602
# General Public License for more details.
384602
#
384602
# You should have received a copy of the GNU General Public License
384602
# along with this program; if not, write to the Free Software
384602
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
384602
#
384602
# ----------------------------------------------------------------------
384602
# $Id$
384602
# ----------------------------------------------------------------------
384602
384602
function svn_getOptions {
384602
384602
    # Define short options we want to support.
384602
    local ARGSS=""
384602
384602
    # Define long options we want to support.
bc39d6
    local ARGSL="sync,update,commit,is-versioned,commit-changes,get-status"
384602
f98b49
    # Redefine ARGUMENTS using getopt(1) command parser.
384602
    cli_parseArguments
384602
384602
    # Redefine positional parameters using ARGUMENTS variable.
384602
    eval set -- "$ARGUMENTS"
384602
384602
    # Look for options passed through command-line.
384602
    while true; do
384602
384602
        case "$1" in
384602
384602
            --sync )
274988
                ACTIONNAMS="${ACTIONNAMS} svn_syncroRepoChanges"
384602
                shift 1
384602
                ;;
384602
384602
            --commit )
384602
                ACTIONNAMS="${ACTIONNAMS} svn_commitRepoChanges"
384602
                shift 1
384602
                ;;
384602
384602
            --update )
384602
                ACTIONNAMS="${ACTIONNAMS} svn_updateRepoChanges"
384602
                shift 1
384602
                ;;
384602
274988
            --is-versioned )
274988
                ACTIONNAMS="${ACTIONNAMS} svn_isVersioned"
384602
                shift 1
384602
                ;;
384602
bc39d6
            --get-status )
bc39d6
                ACTIONNAMS="${ACTIONNAMS} svn_getRepoStatus"
bc39d6
                shift 1
bc39d6
                ;;
bc39d6
f98b49
            --commit-changes )
f98b49
                FLAG_COMMIT_CHANGES="true"
f98b49
                shift 1
f98b49
                ;;
f98b49
f98b49
384602
            -- )
384602
                # Remove the `--' argument from the list of arguments
384602
                # in order for processing non-option arguments
384602
                # correctly. At this point all option arguments have
384602
                # been processed already but the `--' argument still
384602
                # remains to mark ending of option arguments and
384602
                # begining of non-option arguments. The `--' argument
384602
                # needs to be removed here in order to avoid
384602
                # centos-art.sh script to process it as a path inside
384602
                # the repository, which obviously is not.
384602
                shift 1
384602
                break
384602
                ;;
384602
        esac
384602
    done
384602
384602
    # Redefine ARGUMENTS variable using current positional parameters. 
384602
    cli_parseArgumentsReDef "$@"
384602
384602
}