Blame Scripts/Bash/Functions/Render/render_getOptions.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# render_getOptions.sh -- This function interprets option parameters
878a2b
# passed to `render' functionality and calls actions accordingly.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function render_getOptions {
878a2b
878a2b
    # Define short options we want to support.
c8a133
    local ARGSS="q,h"
878a2b
878a2b
    # Define long options we want to support.
c8a133
    local ARGSL="quiet,help,filter:,answer-yes,dont-dirspecific,releasever:,basearch:,post-rendition:,last-rendition:,theme-model:,with-brands,sync-changes"
878a2b
b730f1
    # Redefine ARGUMENTS using getopt(1) command parser.
878a2b
    cli_parseArguments
878a2b
878a2b
    # Redefine positional parameters using ARGUMENTS variable.
878a2b
    eval set -- "$ARGUMENTS"
878a2b
878a2b
    # Look for options passed through command-line.
878a2b
    while true; do
878a2b
878a2b
        case "$1" in
878a2b
c8a133
            -h | --help )
43ea8c
                ${CLI_NAME} help --read --format="texinfo" trunk/Scripts/Bash/Functions/Render
c8a133
                shift 1
c8a133
                exit
878a2b
                ;;
878a2b
d065a6
            -q | --quiet )
d065a6
                FLAG_QUIET="true"
878a2b
                shift 1
878a2b
                ;;
878a2b
c8a133
            --filter )
c8a133
                FLAG_FILTER="$2"
c8a133
                shift 2
c8a133
                ;;
c8a133
878a2b
            --answer-yes )
878a2b
                FLAG_ANSWER="true"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --dont-dirspecific )
878a2b
                FLAG_DONT_DIRSPECIFIC="true"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --post-rendition )
878a2b
                FLAG_POSTRENDITION="$2"
878a2b
                shift 2
878a2b
                ;;
878a2b
878a2b
            --last-rendition )
878a2b
                FLAG_LASTRENDITION="$2"
878a2b
                shift 2
878a2b
                ;;
878a2b
878a2b
            --basearch )
878a2b
                FLAG_BASEARCH="$2"
878a2b
                if [[ ! $FLAG_BASEARCH =~ $(cli_getPathComponent --architecture-pattern) ]];then
878a2b
                    cli_printMessage "`gettext "The architecture provided is not supported."`" --as-error-line
878a2b
                fi
878a2b
                shift 2
878a2b
                ;;
878a2b
878a2b
            --releasever )
878a2b
                FLAG_RELEASEVER="$2"
878a2b
                if [[ ! $FLAG_RELEASEVER =~ $(cli_getPathComponent --release-pattern) ]];then
878a2b
                    cli_printMessage "`gettext "The release version provided is not supported."`" --as-error-line
878a2b
                fi
878a2b
                shift 2
878a2b
                ;;
878a2b
878a2b
            --theme-model )
878a2b
                FLAG_THEME_MODEL=$(cli_getRepoName $2 -d)
878a2b
                shift 2
878a2b
                ;;
878a2b
878a2b
            --with-brands )
878a2b
                FLAG_WITH_BRANDS='true'
878a2b
                shift 1
878a2b
                ;;
878a2b
331307
            --sync-changes )
331307
                FLAG_SYNC_CHANGES='true'
b730f1
                shift 1
b730f1
                ;;
b730f1
878a2b
            -- )
878a2b
                # Remove the `--' argument from the list of arguments
878a2b
                # in order for processing non-option arguments
878a2b
                # correctly. At this point all option arguments have
878a2b
                # been processed already but the `--' argument still
878a2b
                # remains to mark ending of option arguments and
878a2b
                # begining of non-option arguments. The `--' argument
878a2b
                # needs to be removed here in order to avoid
878a2b
                # centos-art.sh script to process it as a path inside
878a2b
                # the repository, which obviously is not.
878a2b
                shift 1
878a2b
                break
878a2b
                ;;
878a2b
        esac
878a2b
    done
878a2b
878a2b
    # Redefine ARGUMENTS variable using current positional parameters. 
878a2b
    cli_parseArgumentsReDef "$@"
878a2b
878a2b
}