#!/bin/bash

set -e

CACHE_CLEAR=1
VERBOSE_LEVEL="-v"

while getopts ":hvs" OPTCHAR; do
    case "${OPTCHAR}" in
        s)
            CACHE_CLEAR=0
            ;;
        h)
            echo -e "Usage: $0 [-v] [-h] [-s] [Provider|Ast|Kam|Cgr]"
            echo
            echo -e "\t-v\tShow version information"
            echo -e "\t-h\tShow this help"
            echo -e "\t-s\tSkip cache clear after generation"
            echo
            exit
            ;;
        v)
            VERBOSE_LEVEL="${VERBOSE_LEVEL}v"
            ;;
    esac
done

shift $(expr $OPTIND - 1 )

pushd /opt/irontec/ivozprovider/schema
    while test $# -gt 0; do
        bin/console ivoz:make:entities $1
        bin/console ivoz:make:interfaces $1
        bin/console ivoz:make:repositories $1
        shift
    done
popd
