.PHONY: run debug clean shell

bin/activate: requirements.txt
	test -f bin/activate || $(shell which python3) -m venv .
	bin/pip install -Ur requirements.txt
	touch bin/activate

run: bin/activate
	. bin/activate; FLASK_SETTINGS_FILE=../config/prod.cfg FLASK_ENV=production FLASK_APP=start.py flask run --host=0.0.0.0

debug: bin/activate
	. bin/activate; FLASK_SETTINGS_FILE=../config/dev.cfg FLASK_ENV=development FLASK_APP=start.py flask run --host=0.0.0.0

clean:
	rm -rf bin/ include/ lib/ lib64/ __pycache__/ share/; rm pyvenv.cfg

shell: bin/activate
	. bin/activate; FLASK_SETTINGS_FILE=../config/dev.cfg FLASK_APP=start.py flask shell

cli: bin/activate
	. bin/activate; FLASK_SETTINGS_FILE=../config/dev.cfg FLASK_APP=start.py flask ${COMMAND}

recreatedb: bin/activate
	. bin/activate; FLASK_SETTINGS_FILE=../config/dev.cfg FLASK_APP=start.py flask acks dropdb
	. bin/activate; FLASK_SETTINGS_FILE=../config/dev.cfg FLASK_APP=start.py flask acks initdb
	. bin/activate; FLASK_SETTINGS_FILE=../config/dev.cfg FLASK_APP=start.py flask npc populate
	
