Blame Scripts/Functions/Tuneup/tuneup_getOptions.sh

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