src/bin/killswitch.rs: CLI entry point (delegates tokillswitch::cli).src/cli/: Argument parsing (clap), dispatch, and user-facing actions.src/killswitch/: Core domain logic (network detection, pf rule generation).- Root docs:
IMPLEMENTATION.md. - CI/config:
.github/workflows/(format/lint/test/coverage),.justfile(local automation).
Prefer just (see .justfile):
just test: Runs format check, clippy, andcargo test.just fmt: Checks formatting viacargo fmt --all -- --check.just clippy: Lints all targets/features viacargo clippy --all-targets --all-features.
Equivalent Cargo commands:
cargo build: Builds the crate.cargo test: Runs unit tests (mostly inline#[test]modules).cargo run -- --help: Runs the CLI and shows flags (use--printto avoid applying pf rules).
- Rust style: run
cargo fmt(CI enforces formatting). - Lints are strict:
Cargo.tomldenies warnings and usesclippy::pedantic; avoidunwrap(),expect(), andpanic!in production code. - Naming: modules/functions
snake_case, types/traitsCamelCase, constantsSCREAMING_SNAKE_CASE. - Prefer explicit error handling with
anyhow::Resultand?.
- Run
just testbefore pushing. - Tests live alongside code (e.g.,
src/cli/**,src/killswitch/**). - Test names follow
test_<component>_<scenario>; only relax lints in tests when needed (e.g.,#[allow(clippy::unwrap_used)]).
- Branching: use git-flow; open PRs against
develop(notmain). See.github/PULL_REQUEST_TEMPLATE.md. - Commit messages in this repo are short and action-oriented (e.g., “fix workflow”, “update dependencies”, “bump version to X”). Keep the subject imperative and include an issue/PR reference when relevant.
- PRs should include: what/why summary, how it was tested (
just testoutput or notes), and any behavior/safety impact (killswitch changes can affect networking).