#!/bin/bash

usage()
{
	printf "\nWelcome,"
	printf "\nThis script is used with the propouse of optimize the branch generation in your project\n"

	printf "\nHow to Use:"
	printf "\n\nA first parameter:"
	printf "\nUse '-M' to specify that a major release will be create"
	printf "\nUse '-m' to specify that a minor release will be create"
	printf "\nUse '-p' to specify that a patch release will be create"
	printf "\nUse '-h' to specify that a hotfix will be create"
	printf "\n\nAnd a second parameter:"
	printf "\nUse '--front' to specify that a branch are of frontend repository"
	printf "\nUse '--back' to specify that a branch are of backend repository"
	printf "\n"
}

invalid()
{
	printf "\n $1 Option or Argument is invalid.\n"
}

. senior-ci/common/senior-ci-extensions-helpers.sh
. senior-ci/common/release-helpers.sh

case $2 in
    --back)
        REPO=back
        ;;
    --front)
        REPO=front
        ;;
    *)
        invalid $2;
        usage;
        exit 1
        ;;
esac

case $1 in
    -M)
        RELEASE_KIND=major
        . senior-ci/release-candidate/common/create_release.sh
        ;;
    -m)
        RELEASE_KIND=minor
        . senior-ci/release-candidate/common/create_release.sh
        ;;
    -p)
        RELEASE_KIND=patch
        . senior-ci/release-candidate/common/create_release.sh
        ;;
    -h)
        RELEASE_KIND=patch
        . senior-ci/release-candidate/common/create_hotfix.sh
        ;;
    *)
        invalid $1;
        usage;
        exit 1
        ;;
esac
