github.com/rochacon/deis@v1.0.2-0.20150903015341-6839b592a1ff/tests/bin/accept/commands/provision/options.sh (about)

     1  # Generated by stubbs:add-option. Do not edit, if using stubbs.
     2  # Created: Thu Jul 23 11:38:40 MDT 2015
     3  #
     4  #/ usage: tests:provision  --provider <vagrant>  --version <dev> [ --skip-cleanup <false>] 
     5  
     6  # _rerun_options_parse_ - Parse the command arguments and set option variables.
     7  #
     8  #     rerun_options_parse "$@"
     9  #
    10  # Arguments:
    11  #
    12  # * the command options and their arguments
    13  #
    14  # Notes:
    15  # 
    16  # * Sets shell variables for any parsed options.
    17  # * The "-?" help argument prints command usage and will exit 2.
    18  # * Return 0 for successful option parse.
    19  #
    20  rerun_options_parse() {
    21  
    22      while [ "$#" -gt 0 ]; do
    23          OPT="$1"
    24          case "$OPT" in
    25              --provider) rerun_option_check $# $1; PROVIDER=$2 ; shift ;;
    26              --version) rerun_option_check $# $1; VERSION=$2 ; shift ;;
    27              --skip-cleanup) rerun_option_check $# $1; SKIP_CLEANUP=$2 ; shift ;;
    28              # help option
    29              -|--*?)
    30                  rerun_option_usage
    31                  exit 2
    32                  ;;
    33              # end of options, just arguments left
    34              *)
    35                break
    36          esac
    37          shift
    38      done
    39  
    40      # Set defaultable options.
    41      [ -z "$PROVIDER" ] && PROVIDER="$(rerun_property_get $RERUN_MODULE_DIR/options/provider DEFAULT)"
    42      [ -z "$VERSION" ] && VERSION="$(rerun_property_get $RERUN_MODULE_DIR/options/version DEFAULT)"
    43      [ -z "$SKIP_CLEANUP" ] && SKIP_CLEANUP="$(rerun_property_get $RERUN_MODULE_DIR/options/skip-cleanup DEFAULT)"
    44      # Check required options are set
    45      [ -z "$PROVIDER" ] && { echo >&2 "missing required option: --provider" ; return 2 ; }
    46      [ -z "$VERSION" ] && { echo >&2 "missing required option: --version" ; return 2 ; }
    47      # If option variables are declared exportable, export them.
    48  
    49      #
    50      return 0
    51  }
    52  
    53  
    54  # If not already set, initialize the options variables to null.
    55  : ${PROVIDER:=}
    56  : ${VERSION:=}
    57  : ${SKIP_CLEANUP:=}
    58  
    59