# Generated by stubbs:add-option. Do not edit, if using stubbs.
# Created: Thu Jul 23 11:38:40 MDT 2015
#
#/ usage: tests:provision  --provider <vagrant>  --version <dev> [ --skip-cleanup <false>] 

# _rerun_options_parse_ - Parse the command arguments and set option variables.
#
#     rerun_options_parse "$@"
#
# Arguments:
#
# * the command options and their arguments
#
# Notes:
# 
# * Sets shell variables for any parsed options.
# * The "-?" help argument prints command usage and will exit 2.
# * Return 0 for successful option parse.
#
rerun_options_parse() {

    while [ "$#" -gt 0 ]; do
        OPT="$1"
        case "$OPT" in
            --provider) rerun_option_check $# $1; PROVIDER=$2 ; shift ;;
            --version) rerun_option_check $# $1; VERSION=$2 ; shift ;;
            --skip-cleanup) rerun_option_check $# $1; SKIP_CLEANUP=$2 ; shift ;;
            # help option
            -|--*?)
                rerun_option_usage
                exit 2
                ;;
            # end of options, just arguments left
            *)
              break
        esac
        shift
    done

    # Set defaultable options.
    [ -z "$PROVIDER" ] && PROVIDER="$(rerun_property_get $RERUN_MODULE_DIR/options/provider DEFAULT)"
    [ -z "$VERSION" ] && VERSION="$(rerun_property_get $RERUN_MODULE_DIR/options/version DEFAULT)"
    [ -z "$SKIP_CLEANUP" ] && SKIP_CLEANUP="$(rerun_property_get $RERUN_MODULE_DIR/options/skip-cleanup DEFAULT)"
    # Check required options are set
    [ -z "$PROVIDER" ] && { echo >&2 "missing required option: --provider" ; return 2 ; }
    [ -z "$VERSION" ] && { echo >&2 "missing required option: --version" ; return 2 ; }
    # If option variables are declared exportable, export them.

    #
    return 0
}


# If not already set, initialize the options variables to null.
: ${PROVIDER:=}
: ${VERSION:=}
: ${SKIP_CLEANUP:=}


