nazara 0.2.1

A CLI application to create and update machines and VMs in NetBox.
.PHONY: all install-pre-commit setup-hooks run-hooks format check clean release help

all: build

help:
	@echo "Available targets:"
	@echo "    audit - Check dependencies for vulnerability reports"
	@echo "    build - Builds the application in release mode"
	@echo "    build-dev - Builds the application with debug symbols enabled. (release-mode off)"
	@echo "    bump-version version=$VERSION - Prepare a release by bumping all version numbers"
	@echo "    format - Format code"v
	@echo "    install-pre-commit - Install pre-commit"
	@echo "    run-hooks - Run pre-commit hooks"
	@echo "    release - Run through the release process"
	@echo "    setup-hooks - Set up pre-commit hooks"
	@echo "    setup - Setup dev enironment"

audit:
	@echo "Running cargo audit..."
	@command -v cargo-audit >/dev/null 2>&1 || \
		(echo "Installing cargo-audit..." && cargo install cargo-audit --locked)
	cargo audit

bump-versions:
	@set -e; \
		if [ -z "$(version)"]; then
			echo "Error: Version undefined. Use: make bump-versions version=v1.2.3";
			exit 1;
		fi; \
			./utils/maintenance/bump_versions.sh $(if $(filter --dry-run, $MAKECMDGOALS)),--dry-run,) $(version) $(FILES)

# Might fail when pip does not allow system wide installation
install-pre-commit:
	@echo "Installing pre-commit..."
	pip install pre-commit || { echo 'Error installing pre-commit'; exit 1; }


setup-hooks:
	@echo "Setting up pre-commit hooks..."
	pre-commit install

run-hooks:
	@echo "Running hooks..."
	pre-commit run --all-files

release:
	@set -e; \
		if [ ! -f Cargo.toml ] || [ ! -f Nazara.spec ]; then
	echo "Error: required files missing"; exit 1; fi; \
		./utils/maintenance/release.sh

release-live:
	@set -e; \
		if [ ! -f Cargo.toml ] || [ ! -f Nazara.spec ]; then
	echo "Error: required files missing"; exit 1; fi; \
		./utils/maintenance/release.sh --live

setup: install-pre-commit setup-hooks run-hooks
	@echo "pre-commit setup completed."

build:
	cargo build --bin --release

build-dev:
	cargo build --bin

code-docs:
	cargo doc --bin nazara  --no-deps --document-private-items --open

docs:
	cargo install mdbook mdbook-admonish mdbook-plantuml
	mdbook build && mdbook serve
	@echo "You can now reach the documentation via 'http://localhost:3000'"

format:
	@echo "Formatting code with 'cargo fmt'..."
	cargo fmt

check:
	@echo "Running clippy check..."
	cargo clippy

clean:
	@echo "Cleaning build artifacts..."
	cargo clean