# Generated by stubbs:add-option. Do not edit, if using stubbs.
# Created: Wed Aug  5 14:11:16 MDT 2015
#
#/ usage: accept:upgrade  --provider <vagrant>  --from <> [ --to <master>] [ --skip-cleanup <false>]  --upgrade-style <graceful> 

# _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 ;;
            --from) rerun_option_check $# $1; FROM=$2 ; shift ;;
            --to) rerun_option_check $# $1; TO=$2 ; shift ;;
            --skip-cleanup) rerun_option_check $# $1; SKIP_CLEANUP=$2 ; shift ;;
            --upgrade-style) rerun_option_check $# $1; UPGRADE_STYLE=$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 "$TO" ] && TO="$(rerun_property_get $RERUN_MODULE_DIR/options/to DEFAULT)"
    [ -z "$SKIP_CLEANUP" ] && SKIP_CLEANUP="$(rerun_property_get $RERUN_MODULE_DIR/options/skip-cleanup DEFAULT)"
    [ -z "$UPGRADE_STYLE" ] && UPGRADE_STYLE="$(rerun_property_get $RERUN_MODULE_DIR/options/upgrade-style DEFAULT)"
    # Check required options are set
    [ -z "$PROVIDER" ] && { echo >&2 "missing required option: --provider" ; return 2 ; }
    [ -z "$FROM" ] && { echo >&2 "missing required option: --from" ; return 2 ; }
    [ -z "$UPGRADE_STYLE" ] && { echo >&2 "missing required option: --upgrade-style" ; return 2 ; }
    # If option variables are declared exportable, export them.

    #
    return 0
}


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


