Blame Scripts/Functions/Render/render_getArguments.sh

4c79b5
#!/bin/bash
4c79b5
#
d3dc02
# render_getArguments.sh -- This function interprets arguments passed to
07c2fe
# render functionality and calls actions accordingly.
4c79b5
#
9f5f2e
# 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
#
dcd347
# This program is distributed in the hope that it will be useful,
dcd347
# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
d3dc02
function render_getArguments {
4c79b5
07c2fe
    # Define short options we want to support.
15b1d2
    local ARGSS=""
4c79b5
07c2fe
    # Define long options we want to support.
61bb5b
    local ARGSL="filter:,quiet,answer:,dont-commit-changes,releasever:,basearch:,convert:,rotate:,resize:,group-by:,theme-model:"
4c79b5
49237e
    # Redefine ARGUMENTS variable using getopt output.
07c2fe
    cli_doParseArguments
4c79b5
49237e
    # Redefine positional parameters using ARGUMENTS variable.
07c2fe
    eval set -- "$ARGUMENTS"
4c79b5
07c2fe
    # Look for options passed through command-line.
07c2fe
    while true; do
4c79b5
07c2fe
        case "$1" in
4c79b5
49237e
            --filter )
49237e
                FLAG_FILTER="$2"
49237e
                shift 2
49237e
                ;;
49237e
49237e
            --quiet )
49237e
                FLAG_QUIET="true"
49237e
                FLAG_DONT_COMMIT_CHANGES="true"
49237e
                shift 1
49237e
                ;;
49237e
49237e
            --answer )
49237e
                FLAG_ANSWER="$2"
49237e
                shift 2
49237e
                ;;
49237e
49237e
            --dont-commit-changes )
49237e
                FLAG_DONT_COMMIT_CHANGES="true"
49237e
                shift 1
49237e
                ;;
49237e
05d9ae
            --releasever )
49237e
                FLAG_RELEASEVER="$2"
49237e
                if [[ ! $FLAG_RELEASEVER =~ $(cli_getPathComponent '--release-pattern') ]];then
05d9ae
                    cli_printMessage "`gettext "The release version provided is not supported."`" 'AsErrorLine'
eee226
                    cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
a615b0
                fi
15b1d2
                shift 2
15b1d2
                ;;
15b1d2
05d9ae
            --basearch )
49237e
                FLAG_BASEARCH="$2"
49237e
                if [[ ! $FLAG_BASEARCH =~ $(cli_getPathComponent '--architecture-pattern') ]];then
a615b0
                    cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine'
eee226
                    cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
a615b0
                fi
a615b0
                shift 2
15b1d2
                ;;
15b1d2
61bb5b
            --convert )
61bb5b
                FLAG_CONVERT="$2"
61bb5b
                shift 2
61bb5b
                ;;
61bb5b
61bb5b
            --rotate )
61bb5b
                FLAG_ROTATE="$2"
61bb5b
                shift 2
61bb5b
                ;;
61bb5b
61bb5b
            --resize )
61bb5b
                FLAG_RESIZE="$2"
ae711e
                shift 2
ae711e
                ;;
ae711e
eb2fa0
            --group-by )
ef0114
                FLAG_GROUPED_BY="$2"
ef0114
                shift 2
ef0114
                ;;
ef0114
ef0114
            --theme-model )
ef0114
                FLAG_THEME_MODEL=$(cli_getRepoName "$2" 'd')
a615b0
                shift 2
07c2fe
                ;;
4c79b5
92df38
            -- )
92df38
                # Remove the `--' argument from the list of arguments
92df38
                # in order for processing non-option arguments
92df38
                # correctly. At this point all option arguments have
92df38
                # been processed already but the `--' argument still
92df38
                # remains to mark ending of option arguments and
92df38
                # begining of non-option arguments. The `--' argument
92df38
                # needs to be removed here in order to avoid
92df38
                # centos-art.sh script to process it as a path inside
92df38
                # the repository, which obviously is not.
92df38
                shift 1
07c2fe
                break
92df38
                ;;
07c2fe
        esac
07c2fe
    done
07c2fe
49237e
    # Redefine ARGUMENTS variable using current positional parameters. 
49237e
    cli_doParseArgumentsReDef "$@"
a615b0
4c79b5
}