Skip to content

feat: add hlz watch command for price alerts with shell triggers#3

Closed
dzmbs wants to merge 2 commits intomainfrom
sym-9/add-watch-command
Closed

feat: add hlz watch command for price alerts with shell triggers#3
dzmbs wants to merge 2 commits intomainfrom
sym-9/add-watch-command

Conversation

@dzmbs
Copy link
Copy Markdown
Owner

@dzmbs dzmbs commented Mar 14, 2026

Summary

Add hlz watch <COIN> --above|--below <PRICE> — a WebSocket-based price watcher that monitors a condition and optionally executes a shell command when triggered.

Changes

src/cli/args.zig

  • Add WatchArgs struct with coin, above, below, cmd, repeat fields
  • Add watch variant to Command union and HelpTopic enum
  • Add parseWatch() with validation: exactly one of --above/--below required
  • Wire into parse() and canonicalHelpTopic()

src/cli/commands.zig

  • Add watch() command: connects to WS allMids, monitors target coin mid price
  • Reconnect loop with max 10 retries, 2s backoff between attempts
  • SIGINT handling reusing stream command pattern
  • TTY output: ⚡ BTC hit 100234.50 (was watching: --above 100000)
  • JSON output when piped or with --json: {"coin":"BTC","price":...,"condition":...,"threshold":...,"timestamp":...}
  • Shell command execution via std.process.Child with /bin/sh -c
  • --repeat flag for continuous monitoring
  • 3 unit tests for extractMidPrice helper

src/cli/main.zig

  • Wire .watch case in main command switch
  • Rename STREAMING section to STREAMING & ALERTS
  • Add watch command help documentation

Testing

  • zig build test — all tests pass (186 including 3 new extractMidPrice tests)
  • zig build hlz — builds successfully
  • zig build hlz-terminal — builds successfully
  • Arg validation: no args (exit 2), no condition (exit 2), both conditions (exit 2)
  • hlz help watch — correct help output

Closes SYM-9

@dzmbs dzmbs added the symphony label Mar 14, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hlz Ready Ready Preview, Comment Mar 14, 2026 10:38pm

- Add edge detection to watchReadLoop: only fire when condition
  transitions from not-met to met (was_met state). Prevents repeated
  cmd execution while price stays on triggered side of threshold.

- Resolve spot pairs (e.g. HYPE/USDC) to @index for allMids lookup
  via resolveSpotCoin, matching other read commands. Display output
  still shows the human-readable pair name.
@dzmbs
Copy link
Copy Markdown
Owner Author

dzmbs commented Mar 14, 2026

Closing for rework — fresh approach

@dzmbs dzmbs closed this Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant