Blame Scripts/Functions/Copy/copy_getOptions.sh

f20852
#!/bin/bash
f20852
#
c2b86b
# copy_getOptions.sh -- This function interprets option parameters
c2b86b
# passed to copy functionality and calls actions accordingly.
f20852
#
2d3646
# Copyright (C) 2009, 2010, 2011 The CentOS Project
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.
7ac5a5
#
f20852
# ----------------------------------------------------------------------
bfd13f
# $Id$
f20852
# ----------------------------------------------------------------------
f20852
c2b86b
function copy_getOptions {
f20852
f20852
    # Define short options we want to support.
f20852
    local ARGSS=""
f20852
f20852
    # Define long options we want to support.
3ccb0a
    local ARGSL="quiet,answer-yes,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
3ccb0a
            --answer-yes )
3ccb0a
                FLAG_ANSWER="true"
3ccb0a
                shift 1
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
}