Expand description
Editor-based content approval, git-commit style.
Opens content in the user’s editor, lets them edit or approve it, and
returns the bytes above the scissors line. Modelled on git’s
commit.cleanup=scissors convention.
Input is UTF-8 text only: non-UTF-8 bytes surface as an I/O error before anything is written.
Structs§
- Options
- Optional knobs for
approve_in_editorandapprove_file_in_place.
Enums§
- File
Error - Errors from
approve_file_in_place. On every error the target file is left exactly as it was: editing happens in a sidecar that is discarded on failure. - File
Outcome - Outcome of an in-place file approval. The approved content is in the file itself; on abort the file is left untouched.
- Outcome
- Result of a stdin-mode approval round-trip.
- Scissors
Error - Errors from
approve_in_editor. The failure cases preserve the draft file and report its path so the user can recover their work.
Constants§
- SCISSORS
- The git scissors separator.
build_draftends the footer with this exact line;strip_scissorscuts at its last occurrence.
Functions§
- approve_
file_ in_ place - Open
pathin the user’s editor, edited in place. The caller ownspath: this never creates or deletes it. - approve_
in_ editor - Open
contentin the user’s editor and return the approved bytes. - resolve_
editor - Resolve the editor command, honouring $VISUAL > $EDITOR >
vi. Returns the command split into program + args (e.g.["code", "--wait"]). - strip_
scissors - Return everything above the last scissors line, trimmed. If there is no scissors line, return the whole input trimmed. Cutting at the last occurrence (the footer is always appended last) preserves a body that itself contains a scissors line, instead of silently discarding everything below it.