You are an agent working on fsrc — a Rust CLI tool that embeds source files into any text file using comment markers. It works with markdown, YAML, Python, Rust, shell scripts, and any file that supports comments.
Single Rust binary (not a workspace). Minimal dependencies: clap and regex.
| File | Role |
|---|---|
src/main.rs |
CLI entry point (clap derive) — --verify, --dry-run flags |
src/embed.rs |
Core processing — finds fsrc src="..." markers, reads source files, replaces content |
src/lang.rs |
ext_to_lang() — maps file extensions to code fence language identifiers |
src/lib.rs |
Library re-exports |
action.yml |
GitHub Action wrapper |
- Scans for lines containing
fsrc src="path"(opening marker) - Finds the corresponding
/fsrc(closing marker) - Replaces content between markers with the referenced file's contents
- Supports raw insertion (default) or code-fenced insertion (
fence,fence="auto",fence="python") - Idempotent — safe to re-run
| Task | Command |
|---|---|
| Build | cargo build --release |
| Test | cargo test |
| Install | cargo install --path . |
| Process files | fsrc run README.md docs/*.md |
| Verify (CI) | fsrc run --verify README.md |
| Dry run | fsrc run --dry-run README.md |
- Rust 2021 edition, Apache-2.0 license
- Regex-based marker parsing (comment-agnostic)
- Backtick fence collision avoidance (
make_fence()) - Tests inline in
embed.rsandlang.rs
Edit src/lang.rs → ext_to_lang() match arms. Add the file extension mapping and a test in the tests module below.