#!/bin/bash
#
# Copyright (c) 2024 Mike Tsao

for f in $(find . -name \*.rs -not -path "./target/*" -not -path "./vendor/*")
do
    if ! grep -q -E '^\/\/ Copyright \(c\) 202[4-9] Mike Tsao$' "$f"
    then
        echo "$f missing header"
        head -n 1 "$f"
        exit 1
    fi
done

# fix style
cargo fmt --all

# generate documentation
cargo doc \
    --no-deps --workspace --document-private-items \
    --examples --features="std hound"

# build and test
cargo test --workspace --examples

# cargo build --no-default-features && \
# this is disabled - see https://github.com/ensnare-org/ensnare/issues/1
