.PHONY: example examples example-requests example-click

DEMO_REPO := target/sniffdiff-demo-python-repo
DEMO_ENV := target/sniffdiff-demo-python-repo.env
REAL_EXAMPLE := scripts/run-real-example.sh

example-repo:
	@mkdir -p target
	@bash scripts/create-example-repo.sh "$(DEMO_REPO)" > "$(DEMO_ENV)"
	@cat "$(DEMO_ENV)"

example: example-repo
	@base=$$(sed -n 's/^SNIFFDIFF_DEMO_BASE=//p' "$(DEMO_ENV)"); \
	head=$$(sed -n 's/^SNIFFDIFF_DEMO_HEAD=//p' "$(DEMO_ENV)"); \
	repo=$$(sed -n 's/^SNIFFDIFF_DEMO_REPO=//p' "$(DEMO_ENV)"); \
	echo ""; \
	cargo run -- --repo "$$repo" "$$base..$$head"


examples: example-requests example-click

example-requests:
	@bash "$(REAL_EXAMPLE)" \
		requests-digest-security \
		https://github.com/psf/requests.git \
		a044b020dea43230585126901684a0f30ec635a8 \
		all

example-click:
	@bash "$(REAL_EXAMPLE)" \
		click-no-such-command \
		https://github.com/pallets/click.git \
		831c8f0948af519e45b90801d7430ff25451f972 \
		8
