Skip to content

Add --help, --version and --watch - #17

Open
Demonstrandum wants to merge 1 commit into
masterfrom
cli-help-watch
Open

Demonstrandum wants to merge 1 commit into
masterfrom
cli-help-watch

Conversation

@Demonstrandum

@Demonstrandum Demonstrandum commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner
  • seam --help / -h lists the formats and options. --version works as well as -v, and both now print to STDOUT. Unknown arguments point to --help.
  • seam --watch / -w rebuilds the given files whenever something they were made from changes. It works for seam run build scripts and for printing a format.

What's watched: whatever the last build read. The expander's Context now records:

  • every file parsed from disk: the inputs, %includes, and %embeds, literate or not
  • the sources of each %write ... :from
  • every %glob pattern; these are re-run on each poll, so new and deleted files are noticed
  • the files written by %write, which are excluded so a build never sets itself off again

Detection polls modification times every 250 ms, so there are no new dependencies and it behaves the same on every OS. A failing build is reported, and the watch continues until the next change. --watch with STDIN is an error.

Context::files_read, globs_searched and files_written are public, so a library user can do the same.

I tested it by hand on a small site: editing an included footer rebuilt every page, adding a post that a glob matches built it and updated the index, and the build's own writes caused no rebuilds.


Note

Low Risk
CLI and bookkeeping changes only; watch uses read-only mtime polling and does not alter expansion semantics beyond recording dependency paths.

Overview
Adds seam --watch / -w, which rebuilds or re-expands the given inputs in a loop whenever dependencies change, until Ctrl-C. The watch set comes from what the last expansion actually used: entry files, reads from %include / %embed, %write ... :from sources, and live results of %glob patterns; outputs from %write are excluded so builds do not trigger themselves. Changes are detected by polling file metadata every 250ms; failed builds are reported and retried on the next change. --watch with STDIN is rejected.

The expander Context now tracks files_read, globs_searched, and files_written (public accessors) so the CLI—and library callers—can mirror that dependency graph.

Also adds seam --help / -h and makes --version / -v print to stdout; unknown flags point users at --help. The binary is refactored around shared build / build_file paths and a documented help string. README and USAGE.md document watch mode and the new help entrypoint.

Reviewed by Cursor Bugbot for commit 1a76f93. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1a76f93. Configure here.

let Some(source) = source.atomic() else {
return Err(ExpansionError::new("`:from` expects paths.", source.site()));
};
self.context.record_read(std::path::Path::new(source.value.as_ref()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch misses write dependency sources

Medium Severity

%write :from sources are recorded only when the destination already exists, and record_read drops paths that are not currently files. --watch therefore never sees those sources on a first build, and never sees a missing source appear, so output can stay stale until some other watched file happens to change.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a76f93. Configure here.

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