Blame Scripts/Bash/Functions/Report/Pppd/pppd_getOptions.sh

1b9e20
#!/bin/bash
1b9e20
#
1b9e20
# pppd_getOptions.sh -- This function interpretes option arguments
1b9e20
# passed to `report' functionality through the command-line and
1b9e20
# defines action names accordingly.
1b9e20
#
1b9e20
# Copyright (C) 2012 Alain Reguera Delgado
1b9e20
#
1b9e20
# This program is free software; you can redistribute it and/or modify
1b9e20
# it under the terms of the GNU General Public License as published by
1b9e20
# the Free Software Foundation; either version 2 of the License, or (at
1b9e20
# your option) any later version.
1b9e20
#
1b9e20
# This program is distributed in the hope that it will be useful, but
1b9e20
# WITHOUT ANY WARRANTY; without even the implied warranty of
1b9e20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1b9e20
# General Public License for more details.
1b9e20
#
1b9e20
# You should have received a copy of the GNU General Public License
1b9e20
# along with this program; if not, write to the Free Software
1b9e20
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1b9e20
#
1b9e20
# ----------------------------------------------------------------------
1b9e20
# $Id$
1b9e20
# ----------------------------------------------------------------------
1b9e20
1b9e20
function pppd_getOptions {
1b9e20
1b9e20
1b9e20
    # Define short options we want to support.
1b9e20
    local ARGSS=""
1b9e20
1b9e20
    # Define long options we want to support.
1b9e20
    local ARGSL="interfaces:,connect-times,first-day:,last-day:"
1b9e20
1b9e20
    # Parse arguments using getopt(1) command parser.
1b9e20
    cli_parseArguments
1b9e20
1b9e20
    # Reset positional parameters using output from (getopt) argument
1b9e20
    # parser.
1b9e20
    eval set -- "$ARGUMENTS"
1b9e20
1b9e20
    # Define action to take for each option passed.
1b9e20
    while true; do
1b9e20
        case "$1" in
1b9e20
1b9e20
            --quiet )
1b9e20
                FLAG_QUIET="true"
1b9e20
                FLAG_DONT_COMMIT_CHANGES="true"
1b9e20
                shift 1
1b9e20
                ;;
1b9e20
1b9e20
            --interfaces )
1b9e20
                FLAG_INTERFACES="$2"
1b9e20
                shift 2
1b9e20
                ;;
1b9e20
1b9e20
            --last-day )
1b9e20
                FLAG_LASTDAY="$2"
1b9e20
                shift 2
1b9e20
                ;;
1b9e20
1b9e20
            --first-day )
1b9e20
                FLAG_FIRSTDAY="$2"
1b9e20
                shift 2
1b9e20
                ;;
1b9e20
1b9e20
            --connect-times )
1b9e20
                ACTIONNAMS="${ACTIONNAMS} outputConnectTimes"
1b9e20
                shift 1
1b9e20
                ;;
1b9e20
1b9e20
            -- )
1b9e20
                # Remove the `--' argument from the list of arguments
1b9e20
                # in order for processing non-option arguments
1b9e20
                # correctly. At this point all option arguments have
1b9e20
                # been processed already but the `--' argument still
1b9e20
                # remains to mark ending of option arguments and
1b9e20
                # begining of non-option arguments. The `--' argument
1b9e20
                # needs to be removed here in order to avoid
1b9e20
                # centos-art.sh script to process it as a path inside
1b9e20
                # the repository, which obviously is not.
1b9e20
                shift 1
1b9e20
                break
1b9e20
                ;;
1b9e20
        esac
1b9e20
    done
1b9e20
1b9e20
    # Redefine ARGUMENTS variable using current positional parameters. 
1b9e20
    cli_parseArgumentsReDef "$@"
1b9e20
1b9e20
}