#!/usr/bin/env zsh

doc="usage: $(basename $0) [-h] [--debug DEBUG [DEBUG ...]]

optional arguments:
  -h, --help            show this help message and exit
  --debug DEBUG [DEBUG ...]
                        debug options
"

zparseopts -D -E -F - h=help -help=help -debug=debug
if (( ${#help} > 0 )); then
    echo ${doc}
    exit 0
fi

set -ex

# https://unix.stackexchange.com/a/64164/549354
setopt extended_glob
cd (../)#pyproject.toml(Y1:a:h)

if (( ${#debug} == 0 )) {
    git_status_porcelain
}

pre-commit run debug-statements -a

git_head=$(git_rev_parse_head)
script=$(odpsrun.py ${git_head} $@)
odpscmd -e ${script}
