Blame Scripts/Functions/Copy/copy_getArguments.sh

f20852
#!/bin/bash
f20852
#
f20852
# copy_getArguments.sh -- This function interprets arguments passed to
f20852
# copy functionality and calls actions accordingly.
f20852
#
f20852
# Copyright (C) 2009-2011 Alain Reguera Delgado
f20852
#
f20852
# This program is free software; you can redistribute it and/or modify
f20852
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
f20852
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
f20852
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
f20852
# General Public License for more details.
f20852
#
f20852
# You should have received a copy of the GNU General Public License
f20852
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
f20852
# ----------------------------------------------------------------------
f20852
# $Id: copy_getArguments.sh 2184 2011-03-30 03:19:31Z al $
f20852
# ----------------------------------------------------------------------
f20852
f20852
function copy_getArguments {
f20852
f20852
    # Define short options we want to support.
f20852
    local ARGSS=""
f20852
f20852
    # Define long options we want to support.
f20852
    local ARGSL="quiet,answer:,dont-commit-changes"
f20852
f20852
    # Redefine ARGUMENTS variable using getopt output.
f20852
    cli_doParseArguments
f20852
f20852
    # Redefine positional parameters using ARGUMENTS variable.
f20852
    eval set -- "$ARGUMENTS"
f20852
f20852
    # Look for options passed through command-line.
f20852
    while true; do
f20852
f20852
        case "$1" in
f20852
f20852
            --quiet )
f20852
                FLAG_QUIET="true"
f20852
                FLAG_DONT_COMMIT_CHANGES="true"
f20852
                shift 1
f20852
                ;;
f20852
f20852
            --answer )
f20852
                FLAG_ANSWER="$2"
f20852
                shift 2
f20852
                ;;
f20852
f20852
            --dont-commit-changes )
f20852
                FLAG_DONT_COMMIT_CHANGES="true"
f20852
                shift 1
f20852
                ;;
f20852
f20852
            -- )
f20852
                # Remove the `--' argument from the list of arguments
f20852
                # in order for processing non-option arguments
f20852
                # correctly. At this point all option arguments have
f20852
                # been processed already but the `--' argument still
f20852
                # remains to mark ending of option arguments and
f20852
                # begining of non-option arguments. The `--' argument
f20852
                # needs to be removed here in order to avoid
f20852
                # centos-art.sh script to process it as a path inside
f20852
                # the repository, which obviously is not.
f20852
                shift 1
f20852
                break
f20852
                ;;
f20852
        esac
f20852
    done
f20852
f20852
    # Redefine ARGUMENTS variable using current positional parameters. 
f20852
    cli_doParseArgumentsReDef "$@"
f20852
f20852
}