Skip to content

feat: add set-callsigns to replace an existing trigger's callsign list - #6

Open
rexington wants to merge 2 commits into
jsvana:mainfrom
rexington:set-callsigns
Open

rexington wants to merge 2 commits into
jsvana:mainfrom
rexington:set-callsigns

Conversation

@rexington

Copy link
Copy Markdown

Summary

Adds a set-callsigns subcommand that replaces the callsign list of one existing trigger with the contents of a file, updating the trigger in place.

My use case: one HamAlert trigger (Source = SOTAwatch, URL action into our club's Slack) covers every member's callsign. I keep that list up to date from the Slack member list. The existing commands can't do this. add-trigger and import-file only create new triggers with callsign and mode conditions, and edit is interactive.

hamalert-cli set-callsigns --trigger-id <id> --file callsigns.txt               # dry run: prints +added / -removed
hamalert-cli set-callsigns --trigger-id <id> --file callsigns.txt --no-dry-run  # apply
hamalert-cli set-callsigns --comment "SOTA spots" --file callsigns.txt          # select by exact comment

Behavior

  • The file is read with the same rules as import-file: one callsign per line, with # and // comments skipped. Callsigns are uppercased and deduplicated.
  • Only conditions.callsign changes. It's written back in the shape it was read: a comma-separated string with the same separator, a newline-separated string, or an array. All other conditions, actions, the comment, and options are left as they were. The update goes through the existing update_trigger() with _id, so the trigger ID doesn't change.
  • It errors clearly if the trigger uses fullCallsign instead of callsign or has no callsign condition, and if --comment matches zero or several triggers.
  • Safeguards:
    • Dry run by default.
    • Refuses an empty file.
    • Refuses to remove more callsigns than --max-removals (default: 10% of the current list, minimum 5). The dry run warns ahead of time when an apply would be refused.
    • After saving, it fetches the trigger again and errors if the saved list doesn't match. This catches the case where HamAlert returns 200 without saving.

Changes

  • src/main.rs: the new subcommand and handler, plus pure helpers (parse_callsign_file, parse_callsign_condition, apply_callsigns, diff_callsigns, removal_limit, select_trigger) and 8 unit tests for them. As elsewhere in the repo, there are no network tests.
  • README.md and the bundled skill (commands.md, safety.md, workflows.md) document the new command.

Testing

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, and cargo test all pass (49 tests).
  • Not yet run against a live trigger. The real-account check (dry run, apply, then diffing backup before and after) is still to do, and I'll report back here when it's done.

🤖 Generated with Claude Code

rexington and others added 2 commits October 7, 2026 17:20
Updates an existing trigger in place from a callsign file, changing only
conditions.callsign and keeping its original string/array shape. Dry-run
by default; refuses an empty file or removals beyond --max-removals
(default 10% of the list, minimum 5), and reads the trigger back after
saving to verify the update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant