Blame Scripts/Functions/Locale/locale_getOptions.sh

4c79b5
#!/bin/bash
4c79b5
#
9fe4a2
# locale_getOptions.sh -- This function interprets option parameters
80bc6f
# passed to `locale' functionality and defines action names
80bc6f
# accordingly.
4c79b5
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
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
80bc6f
# the Free Software Foundation; either version 2 of the License, or
80bc6f
# (at 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
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.
7ac5a5
#
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
9fe4a2
function locale_getOptions {
4c79b5
6c8ab9
    # Define short options we want to support.
786ebb
    local ARGSS=""
4c79b5
6c8ab9
    # Define long options we want to support.
80bc6f
    local ARGSL="filter:,quiet,answer-yes,dont-commit-changes,update,edit,delete,dont-create-mo"
4c79b5
6c8ab9
    # Parse arguments using getopt(1) command parser.
793c4c
    cli_parseArguments
4c79b5
6c8ab9
    # Reset positional parameters using output from (getopt) argument
6c8ab9
    # parser.
6c8ab9
    eval set -- "$ARGUMENTS"
4c79b5
bf6bff
    # Look for options passed through command-line.
6c8ab9
    while true; do
6c8ab9
        case "$1" in
6c8ab9
d74c16
            --filter )
d74c16
                FLAG_FILTER="$2"
d74c16
                shift 2
d74c16
                ;;
d74c16
d74c16
            --quiet )
d74c16
                FLAG_QUIET="true"
d74c16
                FLAG_DONT_COMMIT_CHANGES="true"
d74c16
                shift 1
d74c16
                ;;
d74c16
3ccb0a
            --answer-yes )
3ccb0a
                FLAG_ANSWER="true"
3ccb0a
                shift 1
d74c16
                ;;
d74c16
d74c16
            --dont-commit-changes )
d74c16
                FLAG_DONT_COMMIT_CHANGES="true"
d74c16
                shift 1
d74c16
                ;;
d74c16
786ebb
            --update )
80bc6f
                ACTIONNAMS="$ACTIONNAMS ${FUNCNAM}_updateMessages"
d74c16
                shift 1
6c8ab9
                ;;
6c8ab9
6c8ab9
            --edit )
80bc6f
                ACTIONNAMS="$ACTIONNAMS ${FUNCNAM}_editMessages"
80bc6f
                shift 1
80bc6f
                ;;
80bc6f
80bc6f
            --delete )
80bc6f
                ACTIONNAMS="$ACTIONNAMS ${FUNCNAM}_deleteMessages"
d74c16
                shift 1
6c8ab9
                ;;
6c8ab9
0d4faa
            --dont-create-mo )
0d4faa
                FLAG_DONT_CREATE_MO="true"
6a8fb5
                shift 1
6a8fb5
                ;;
6a8fb5
763e48
            -- )
763e48
                # Remove the `--' argument from the list of arguments
763e48
                # in order for processing non-option arguments
763e48
                # correctly. At this point all option arguments have
763e48
                # been processed already but the `--' argument still
763e48
                # remains to mark ending of option arguments and
763e48
                # begining of non-option arguments. The `--' argument
763e48
                # needs to be removed here in order to avoid
763e48
                # centos-art.sh script to process it as a path inside
763e48
                # the repository, which obviously is not.
763e48
                shift 1
6c8ab9
                break
4e4b4d
                ;;
6c8ab9
        esac
6c8ab9
    done
6c8ab9
80bc6f
    # Verify action names. When no action name is specified, use
80bc6f
    # edition as default action name.
80bc6f
    if [[ $ACTIONNAMS == '' ]];then
80bc6f
        ACTIONNAMS="${FUNCNAM}_editMessages"
80bc6f
    fi
80bc6f
d74c16
    # Redefine ARGUMENTS variable using current positional parameters. 
793c4c
    cli_parseArgumentsReDef "$@"
bf6bff
80bc6f
    # Verify non-option arguments passed to command-line. If there
80bc6f
    # isn't any, redefine the ARGUMENTS variable to use the current
80bc6f
    # location the functionality was called from.
80bc6f
    if [[ $ARGUMENTS == '' ]];then
80bc6f
        ARGUMENTS=${PWD}
80bc6f
    fi
80bc6f
4c79b5
}