#!/bin/sh

# Stop on error.
set -e

# python3 path
python3_bin=`which python3`
kclvm_install_dir=$(cd `dirname $0`/..; pwd)
pip_install_done_file="$kclvm_install_dir/lib/site-packages/kclvm.requirements.done.txt"

# check python3
if [ -z "$python3_bin" ]; then
    echo "python3 not found!"
    exit 1
fi

if [ ! -f $pip_install_done_file ]; then
    # check python3 version
    $python3_bin -c "import sys; sys.exit(0) if sys.version_info>=(3,7,3) else (print('please install python 3.7.3+') or sys.exit(1))"
fi

export KCLVM_CLI_BIN_PATH=$kclvm_install_dir/bin
$python3_bin -m kclvm.tools.format "$@"
