DATA_BACKUP_DIR = "J:/Coastal/Temp/CKL/nsw_2016_storm_impact/data"

#################################################################################
# PROJECT RULES                                                                 #
#################################################################################
.PHONY: push-data mat_to_csv sites-csv-to-shp

push-data: ##@data Copies data from ./data/ to data backup directory
	rclone copy ./data/ $(DATA_BACKUP_DIR) --exclude "*.las" --progress

pull-data: ##@data Copies data from data backup directory to ./data/
	# We probably don't want to pull the raw LIDAR .las files, so lets exclude them
	rclone copy $(DATA_BACKUP_DIR) ./data/ --exclude "*.las" --progress

mat-to-csv: ##@data Converts raw .mat files to .csv for python
	cd ./src/data/ && python mat_to_csv.py

sites-csv-to-shp: ##@data Create the sites.shp from sites.csv
	cd ./src/data && python csv_to_shp.py sites_csv_to_shp "..\..\data\interim\sites.csv" "..\..\data\interim\sites.shp"

#################################################################################
# Self Documenting Commands                                                     #
#################################################################################
.DEFAULT_GOAL := help
.PHONY: help

# Refer to https://gist.github.com/prwhite/8168133

#COLORS
GREEN  := $(shell tput -Txterm setaf 2)
WHITE  := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET  := $(shell tput -Txterm sgr0)

# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
	%help; \
	while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
	print "usage: make [target]\n\n"; \
	for (sort keys %help) { \
	print "${WHITE}$$_:${RESET}\n"; \
	for (@{$$help{$$_}}) { \
	$$sep = " " x (32 - length $$_->[0]); \
	print "  ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
	}; \
	print "\n"; }

help: ##@other Show this help.
	@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)