Blame Scripts/Functions/Locale/locale_getArguments.sh

4c79b5
#!/bin/bash
4c79b5
#
057dc5
# locale_getArguments.sh -- This function interprets arguments passed to
6c8ab9
# `locale' 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
057dc5
function locale_getArguments {
4c79b5
6c8ab9
    # Define short options we want to support.
786ebb
    local ARGSS=""
4c79b5
6c8ab9
    # Define long options we want to support.
8210e9
    local ARGSL="filter:,quiet,answer:,dont-commit-changes,update,edit,dont-create-mo"
4c79b5
6c8ab9
    # Parse arguments using getopt(1) command parser.
6c8ab9
    cli_doParseArguments
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
d74c16
            --answer )
d74c16
                FLAG_ANSWER="$2"
d74c16
                shift 2
d74c16
                ;;
d74c16
d74c16
            --dont-commit-changes )
d74c16
                FLAG_DONT_COMMIT_CHANGES="true"
d74c16
                shift 1
d74c16
                ;;
d74c16
786ebb
            --update )
4e4b4d
                ACTIONNAM="${FUNCNAM}_updateMessages"
d74c16
                shift 1
6c8ab9
                ;;
6c8ab9
6c8ab9
            --edit )
4e4b4d
                ACTIONNAM="${FUNCNAM}_editMessages"
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
d74c16
    # Redefine ARGUMENTS variable using current positional parameters. 
d74c16
    cli_doParseArgumentsReDef "$@"
bf6bff
4c79b5
}