#!/usr/bin/env bash
# ──────────────────────────────────────────────────────────────────────────────
# $vcsh: dotfiles$
# ──────────────────────────────────────────────────────────────────────────────
#
# NAME
#      clear - clear the terminal with any method available
#
# SEE ALSO
#      clear_console(1), clear(1)
#
set -eu -o pipefail

this=$(basename ${0})

if test "${VIRTUAL_ENV:-}" == ""; then
  echo "error: you must enter a virtual environment" >&2
  exit 1
fi

if ! type bump-my-version >/dev/null 2>&1; then
  echo "error: 'bump-my-version' not found" >&2
  exit 1
fi

# If on master branch, then release an official version
if test $(git branch --show-current) != "main"; then
  echo "warning: you are not on 'main' branch. press enter to continue" >&2
  read n
fi

if test -z "${1:-}"; then
  exec bump-my-version show-bump
fi

# Ensure that HEAD is latest
# The following is done in pyproject.toml pre_commit_hooks:
#   precommit run --all
#   precommit autoupdate
git pull || true
as_ver=$1
shift

bump-my-version bump --dry-run --new-version "${as_ver}" "$@"
bump-my-version bump --new-version "${as_ver}" "$@"
