This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
hamalert-cli is a Rust CLI tool for managing HamAlert.org triggers. It allows amateur radio operators to create alerts for specific callsigns and import callsign lists from Ham2K PoLo notes.
cargo build # Debug build
cargo build --release # Release build
cargo test # Run all tests
cargo fmt --all -- --check # Check formatting
cargo clippy --all-targets --all-features -- -D warnings # Lint (warnings are errors)All PRs must pass:
cargo fmtformatting checkcargo clippywith warnings as errorscargo testwith all features
This is a single-file Rust application (src/main.rs) with ~420 lines. The monolithic design is intentional for a simple CLI tool.
Key components in main.rs:
Configstruct: Loads credentials from~/.config/hamalert/config.tomlCli/Commandsenums: clap-based CLI parsing with two subcommandslogin(): Authenticates with HamAlert.org, returns session-enabled clientadd_trigger(): POSTs trigger data to HamAlert APIparse_polo_notes_content(): Extracts callsigns from Ham2K PoLo format (well-tested)fetch_polo_notes(): HTTP GET for remote PoLo notes files- Profile commands: Manage location/activity-based trigger sets (home, portable, contest, etc.)
- Permanent triggers: Triggers that persist across all profile switches, stored in
~/.local/share/hamalert/permanent.json - Profile storage: Saved profiles stored in
~/.local/share/hamalert/profiles/
Data flow:
- Parse CLI args → load config → login to HamAlert.org
- For
add-trigger: POST all callsigns as a single comma-separated trigger - For
import-polo-notes: Fetch URL → parse callsigns → POST each as trigger (or dry-run)
The tool authenticates via POST to https://hamalert.org/ajax/user_login and creates triggers via https://hamalert.org/ajax/trigger_update. Session cookies are maintained in the reqwest client.
Tests are unit tests for parse_polo_notes_content() only (13 tests). No integration tests for API calls exist to avoid external dependencies.
cargo test # Run all tests
cargo test test_parse_polo_notes # Run specific test groupUsers must create ~/.config/hamalert/config.toml:
username = "your_username"
password = "your_password"Git tags matching v* trigger automated multi-platform builds (Linux x64/ARM64, macOS x64/ARM64, Windows x64) via GitHub Actions.