ERROR := \x1b[0;91m
INFO := \x1b[0;94m
NC := \x1b[0m
define show_help_message
echo "Usage: make TARGET"
echo ""
echo "Commands:"
grep -hE '^[A-Za-z0-9_ \-]*?:.*##.*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " $(INFO)%-12s$(NC) %s\n", $$1, $$2}'
endef
define show_error_message
echo "$(ERROR)[Error] $(1)$(NC)"
endef
PREFIX ?= /usr/local
.PHONY: all
all: build
.PHONY: help
help:
@$(show_help_message)
.PHONY: clean
clean:
@cargo clean
.PHONY: r
r: run
.PHONY: run
run:
@cargo run --quiet
.PHONY: b
b: build
.PHONY: build
build:
@cargo build --release
.PHONY: l
l: lint
.PHONY: lint
lint:
@pre-commit run --all-files
.PHONY: check
check:
@rustup update
@cargo fmt
@cargo doc --no-deps --all-features
@cargo check
@cargo clippy --all-targets --all-features -- -D warnings -W clippy::all -W clippy::cargo -W clippy::complexity -W clippy::correctness -W clippy::nursery -W clippy::pedantic -W clippy::perf -W clippy::style -W clippy::suspicious -A clippy::option_if_let_else -A clippy::missing-const-for-fn @make test
@make coverage-pct
.PHONY: t
t: test
.PHONY: test
test:
@cargo test
.PHONY: doc
doc:
@cargo doc --all-features --document-private-items
@echo file://$(shell pwd)/target/doc/$(shell basename $(shell pwd))/index.html
.PHONY: c
c: coverage
.PHONY: coverage
coverage:
@cargo tarpaulin --engine Llvm --timeout 120 --skip-clean --out Html --output-dir target/ --all-features
@echo file://$(shell pwd)/target/tarpaulin-report.html
.PHONY: cpc
cpc: coverage-pct
.PHONY: coverage-pct
coverage-pct:
@coverage=$$(cargo tarpaulin --engine Llvm --out Stdout --all-features 2>&1); \
percent_covered=$$(echo "$$coverage" | grep -o '^[0-9]\+\.[0-9]\+% coverage' | cut -d'%' -f1); \
echo $$percent_covered; \
[ $$(echo "$$percent_covered == 100" | bc -l) -eq 0 ] && exit 1; \
exit 0
.PHONY: install
install:
install -d $(PREFIX)/bin/
install ./target/release/git-slides $(PREFIX)/bin/git-slides
%:
@$(call show_error_message,Unknown command '$@')
@$(show_help_message)