Blame Scripts/Functions/Help/help_getArguments.sh

4c79b5
#!/bin/bash
4c79b5
#
0211a4
# help_getArguments.sh -- This function interpretes arguments passed
2bd980
# to `manual' functionality and calls actions accordingly.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# 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
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
0211a4
function help_getArguments {
4c79b5
2bd980
    # Define short options we want to support.
2bd980
    local ARGSS=""
2bd980
2bd980
    # Define long options we want to support.
75af33
    local ARGSL="filter:,quiet,answer:,dont-commit-changes,read,search,edit,update"
2bd980
2bd980
    # Parse arguments using getopt(1) command parser.
2bd980
    cli_doParseArguments
2bd980
2bd980
    # Reset positional parameters using output from (getopt) argument
2bd980
    # parser.
2bd980
    eval set -- "$ARGUMENTS"
2bd980
2bd980
    # Define action to take for each option passed.
2bd980
    while true; do
2bd980
        case "$1" in
2bd980
c145a8
            --filter )
c145a8
                FLAG_FILTER="$2"
c145a8
                shift 2
c145a8
                ;;
c145a8
c145a8
            --quiet )
c145a8
                FLAG_QUIET="true"
c145a8
                FLAG_DONT_COMMIT_CHANGES="true"
c145a8
                shift 1
c145a8
                ;;
c145a8
c145a8
            --answer )
c145a8
                FLAG_ANSWER="$2"
c145a8
                shift 2
c145a8
                ;;
c145a8
c145a8
            --dont-commit-changes )
c145a8
                FLAG_DONT_COMMIT_CHANGES="true"
c145a8
                shift 1
c145a8
                ;;
c145a8
638bf8
            --search )
2bd980
                ACTIONNAM="${FUNCNAM}_searchIndex"
c145a8
                shift 1
2bd980
                ;;
4c79b5
    
2bd980
            --edit )
2bd980
                ACTIONNAM="${FUNCNAM}_editEntry"
c145a8
                shift 1
2bd980
                ;;
4c79b5
    
638bf8
            --update )
5285d6
                ACTIONNAM="${FUNCNAM}_updateOutputFiles"
c145a8
                shift 1
2bd980
                ;;
4c79b5
    
bbb90e
            --read | * )
bbb90e
                ACTIONNAM="${FUNCNAM}_searchNode"
bbb90e
                FLAG_DONT_COMMIT_CHANGES='true'
2bd980
                break
bbb90e
                ;;
2bd980
        esac
2bd980
    done
2bd980
c145a8
    # Redefine ARGUMENTS variable using current positional parameters. 
c145a8
    cli_doParseArgumentsReDef "$@"
b88dec
4c79b5
}