coverage_opt=--cov  --cov-report=term-missing:skip-covered --durations=10

target=dev

clean:
	pipenv --rm

install:
	pipenv install

install_dev:
	pipenv install --dev
	make requirements

run_dev:
	git ls-files | entr -r	pipenv run python dev.py

tdd:
	git ls-files | entr  make test opt='$(opt)'
	git ls-files | entr make functionnal_tests

refactor_tdd:
	make tdd opt="--pdb --ff --lf --ff -x"


watch_db:
	watch "sqlite3 db_$(target).sqlite3  'select count(*) from movies'"


test:
	pipenv run pytest $(coverage_opt) $(opt) utests

functionnal_tests:
	pipenv run python -m pytest functionnal_test.py

requirements:
	pipenv requirements >  requirements.txt
	pipenv requirements --dev-only >  requirements_dev.txt

docs:
	cd docs/ && make html
	cd docs && firefox ./_build/html/README.html ./_build/html/index.html &

.PHONY: docs

venv_install:
	make -f MakefileVenv install_dev


venv_test:
	make -f MakefileVenv test

db_clean: db_delete
	touch db_$(target).sqlite3

db_fill:
	pipenv run python database.py


db_delete:
	([ -f db_$(target).sqlite3 ] && rm db_$(target).sqlite3) || echo "No file db_$(target).sqlite3 to drop"


db_save:
	cp -f db_$(target).sqlite3 backup_$(USER)_$(target).sqlite3

db_restore:
	cp  backup_$(USER)_$(target).sqlite3 db_$(target).sqlite3




db_reset: db_clean db_fill

