Blame Scripts/Bash/Functions/Prepare/prepare_getOptions.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# prepare_getOptions.sh -- This function parses command options
878a2b
# provided to `centos-art.sh' script when the first argument in the
878a2b
# command-line is the `prepare' word. To parse options, this function
878a2b
# makes use of getopt program.
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 prepare_getOptions {
878a2b
878a2b
    # Define short options we want to support.
878a2b
    local ARGSS=""
878a2b
878a2b
    # Define long options we want to support.
48eaaf
    local ARGSL="quiet,answer-yes,packages,locales,links,images,manuals,set-environment,see-environment"
878a2b
878a2b
    # Parse arguments using getopt(1) command parser.
878a2b
    cli_parseArguments
878a2b
878a2b
    # Reset positional parameters using output from (getopt) argument
878a2b
    # parser.
878a2b
    eval set -- "$ARGUMENTS"
878a2b
878a2b
    # Look for options passed through command-line.
878a2b
    while true; do
878a2b
        case "$1" in
878a2b
878a2b
            --quiet )
878a2b
                FLAG_QUIET="true"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --answer-yes )
878a2b
                FLAG_ANSWER="true"
878a2b
                shift 1
878a2b
                ;;
878a2b
48eaaf
            --set-environment )
48eaaf
                ACTIONNAMS="${ACTIONNAMS} prepare_updateEnvironment"
48eaaf
                shift 1
48eaaf
                ;;
48eaaf
48eaaf
            --see-environment )
48eaaf
                ACTIONNAMS="${ACTIONNAMS} prepare_seeEnvironment"
48eaaf
                shift 1
48eaaf
                ;;
48eaaf
878a2b
            --packages )
878a2b
                ACTIONNAMS="${ACTIONNAMS} prepare_updatePackages"
878a2b
                shift 1
878a2b
                ;;
878a2b
48eaaf
            --locales )
48eaaf
                ACTIONNAMS="${ACTIONNAMS} prepare_updateLocales"
48eaaf
                shift 1
48eaaf
                ;;
48eaaf
878a2b
            --links )
878a2b
                ACTIONNAMS="${ACTIONNAMS} prepare_updateLinks"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --images )
878a2b
                ACTIONNAMS="${ACTIONNAMS} prepare_updateImages"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --manuals )
878a2b
                ACTIONNAMS="${ACTIONNAMS} prepare_updateManuals"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            * )
878a2b
                break
878a2b
        esac
878a2b
    done
878a2b
878a2b
}