Skip to content

Draft: run a command per message with listen --exec - #221

Draft
pinjun99 wants to merge 1 commit into
reason-machines:mainfrom
pinjun99:feat/listen-exec-120
Draft

pinjun99 wants to merge 1 commit into
reason-machines:mainfrom
pinjun99:feat/listen-exec-120

Conversation

@pinjun99

Copy link
Copy Markdown

This is a draft following the shape discussed in #120. Serialization and the timeout are still open on the issue; I'm happy to change either to whatever is decided.

What changed:

  • listen --exec <command> keeps listening and runs a shell command for each message, one at a time and in inbox order, with the same framed text listen already prints on stdin.
  • Only a successful run marks that message delivered. A non-zero exit or a timeout leaves that message and later mail unread, then listen exits, so the next run can pick it up. The default timeout is 60 seconds (--exec-timeout).
  • Without --exec, listen is still one-shot. With --exec it stays up until a failed command or Ctrl+C, because the issue is about not wrapping listen in a shell loop. --wait is the per-poll wait (default 600); --wait 0 drains mail that is already waiting and exits. Empty polls with --wait > 0 wait again.
  • README, DESIGN.md, and the CLI help describe this.

Testing:

  • cargo fmt --check passed.
  • cargo clippy --all-targets -- -D warnings passed.
  • cargo test: 354 passed (347 unit tests, 5 in tests/config_typo.rs, 2 in tests/install_script.rs).
  • New tests cover success (stdin is read), non-zero exit (nothing delivered; later messages stay unread), timeout (child and its process group are killed), and a burst running one at a time in order with the framed stdin text.
  • I did not runtime-test the Windows cmd /C path.

Written with help from an AI coding assistant; I reviewed the change and ran the checks above.

Refs #120

Listen can keep running a shell command for each message, one at a time,
with the framed message on stdin. A failed or timed-out command leaves
that message unread. The default timeout is 60s (--exec-timeout).
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