default:
    @just --list

build:
    cargo build --workspace

release:
    cargo build --workspace --release

check:
    cargo check --workspace
    cargo clippy --workspace

test:
    cargo test --workspace

fmt:
    cargo fmt --all

plugin name:
    cargo build -p owlry-plugin-{{name}} --release

plugins:
    cargo build --workspace --release

show-versions:
    @for dir in crates/owlry-plugin-*; do \
        name=$$(basename $$dir); \
        version=$$(grep '^version' $$dir/Cargo.toml | head -1 | cut -d'"' -f2); \
        printf "%-35s %s\n" "$$name" "$$version"; \
    done

bump-crate crate new_version:
    @cd crates/{{crate}} && \
    sed -i 's/^version = ".*"/version = "{{new_version}}"/' Cargo.toml
    @echo "Bumped {{crate}} to {{new_version}}"

bump-all new_version:
    @for dir in crates/owlry-plugin-*; do \
        sed -i 's/^version = ".*"/version = "{{new_version}}"/' $$dir/Cargo.toml; \
    done
    @echo "Bumped all crates to {{new_version}}"

install-local:
    just plugins
    @for f in target/release/libowlry_plugin_*.so; do \
        sudo install -Dm755 "$$f" /usr/lib/owlry/plugins/$$(basename "$$f"); \
    done
    @echo "Installed all plugins"
