#!/usr/bin/env bash
# A simple configuration file for my vim session
# This file sets up the Makefile and the ENV vars for my vim config.

# Fake `realpath` when it doesn't exist. This only really happens on
# GitHub actions' MacOS runner, since the system does not come with
# a realpath implementation by default, though it can be installed
# using `brew`.
if ! command -v realpath &> /dev/null
then
		realpath() {
			echo $PWD
		}
fi

generate_makefile() {
    echo "\
# This file is generated by \`. project-config\`. Any changes made here are overwritten.

.PHONY: all test cover
PROJECT = $VIM_PROJNAME

install:
	pip3 install -e .

all:
	make install format lint list-todo

format:
	isort \$(PROJECT) && black \$(PROJECT)

lint:
	pylint \$(PROJECT)

lint-prose:
	python3 utils/lint_prose.py

type:
	mypy \$(PROJECT)

list-todo:
	python3 utils/list_todos.py \"\`grep -rnw . -e '# TODO'\`\"

test:
	pytest --cov='./pytermgui'

cover:
	coverage html

test-cov:
	make test cover

docs:
	pdoc --logo https://github.com/bczsalba/pytermgui/blob/master/assets/title.png?raw=true --docformat google -o docs pytermgui" > $VIM_PROJPATH/Makefile

}

export VIM_PROJNAME="pytermgui"
export VIM_PROJPATH="$(realpath `dirname $BASH_SOURCE`)"
# export VIM_COMMAND="python3 $VIM_PROJPATH/sandbox/.py"
# export VIM_NOTES="$VIM_PROJPATH/notes.md"

generate_makefile
echo "Set up project \"$VIM_PROJNAME\" at path \"$VIM_PROJPATH\"."
