#!/bin/bash
# (Copyright) [2016 - 2016] Confluent, Inc.

#
# Use shellcheck to lint this file
#

set -ue

usage() {
  echo "$(basename "$0")": ERROR: "$*" 1>&2
  echo usage: "$(basename "$0")" 'props_file' [--dryRun] 1>&2
  exit 1
}

props_file=""
dryRun=false
EXTRA_ARGS=()
while [ $# -gt 0 ]; do
  case "$1" in
    --dryRun) #Dry-run option
      dryRun=true
      shift
      ;;
    -*) #Pass through anything else that begins with -
      EXTRA_ARGS+=("$1")
      shift
      ;;
    *) #Treat anything else as properties file
      props_file="$1"
      shift
      ;;
  esac
done

if [ -z "$props_file" ]
then
  usage "Properties file is required"
fi

bin_dir=$(dirname "$0")
if [ "$dryRun" = true ]; then
  exec "$bin_dir"/control-center-run-class io.confluent.controlcenter.tools.Resetter "$props_file" "--dryRun"
else
  exec "$bin_dir"/control-center-run-class io.confluent.controlcenter.tools.Resetter "$props_file"
fi