Documentation
¶
Overview ¶
Package takes manages candidate takes and the selected slot for a reel workspace (spec 0001 §3.2 "take management"; contract 0002 §2, R-WS-1). N candidate takes are generated into <kind>/takes/, then one is *selected* — promoted to the committed slot that assembly consumes. This replaces the manual `cp take vo/NN.mp3`. Pure afero logic; unit-tested in memory.
Index ¶
- Variables
- func CardSelected(ws string, card int, ext string) string
- func CardTake(ws string, card, take int, ext string) string
- func CardTakesDir(ws string) string
- func CommitDiscard(fs afero.Fs, ws, rel string) error
- func CoverSelected(ws string) string
- func CoverTake(ws string, take int, ext string) string
- func CoverTakesDir(ws string) string
- func Current(fs afero.Fs, ws string, takeRels []string, selFor func(name string) string) string
- func Discard(fs afero.Fs, ws, rel string) error
- func DiscardedPath(ws, rel string) string
- func HasCardSelected(fs afero.Fs, ws string, card int) bool
- func HasVOSelected(fs afero.Fs, ws string, line int) bool
- func IsPromoted(fs afero.Fs, ws, rel string) bool
- func ListCardTakes(fs afero.Fs, ws string, card int) []string
- func ListCoverTakes(fs afero.Fs, ws string) []string
- func ListMusicTakes(fs afero.Fs, ws string) []string
- func ListPortraitTakes(fs afero.Fs, ws string) []string
- func ListVOTakes(fs afero.Fs, ws string, line int) []string
- func MusicSelected(ws string) string
- func MusicTake(ws string, take int) string
- func MusicTakesDir(ws string) string
- func NextCardTake(fs afero.Fs, ws string, card int, ext string) int
- func NextCoverTake(fs afero.Fs, ws string) int
- func NextMusicTake(fs afero.Fs, ws string) int
- func NextPortraitTake(fs afero.Fs, ws string) int
- func NextVOTake(fs afero.Fs, ws string, line int) int
- func ParseCardTake(name string) (card, take int, ext string, err error)
- func ParseTake(name string) (take int, ext string, err error)
- func PortraitSelected(ws string) string
- func PortraitTake(ws string, take int, ext string) string
- func PortraitTakesDir(ws string) string
- func Prune(fs afero.Fs, ws string) error
- func Restore(fs afero.Fs, ws, rel string) error
- func SelectCard(fs afero.Fs, ws string, card, take int, ext string) error
- func SelectCover(fs afero.Fs, ws string, take int) error
- func SelectMusic(fs afero.Fs, ws string, take int) error
- func SelectPortrait(fs afero.Fs, ws string, take int) error
- func SelectVO(fs afero.Fs, ws string, line, take int) error
- func SetCard(fs afero.Fs, ws string, card int, src string) error
- func SlotFor(ws, rel string) string
- func VOSelected(ws string, line int) string
- func VOTake(ws string, line, take int) string
- func VOTakesDir(ws string) string
Constants ¶
This section is empty.
Variables ¶
var ErrNoTake = errors.NewSentinel("keyrx.no_take", "take not found")
ErrNoTake is returned when a requested take does not exist.
var ErrNotATake = errors.NewSentinel("keyrx.not_a_take", "not a take")
ErrNotATake is returned for a path that is not a candidate take at all.
var ErrTakeInUse = errors.NewSentinel("keyrx.take_in_use", "take is currently promoted")
ErrTakeInUse is returned when the take is the promoted one — discarding it would leave its slot dangling mid-edit, so promote another first (0041 D5).
Functions ¶
func CardTakesDir ¶
CardTakesDir is the directory holding a workspace's candidate card takes.
func CommitDiscard ¶ added in v0.9.0
CommitDiscard makes the discard final by dropping the parked copy. The blob in the object store is untouched — `media gc --prune` reclaims it safely (D2). Committing something already gone is fine: the end state is what was asked for.
func CoverSelected ¶
func CoverTakesDir ¶
func Current ¶ added in v0.9.0
Current reports which of the ws-relative candidate takes is the one in use: promote() copies bytes into the selected slot, so the take whose content equals the slot resolved by selFor (given the take's base filename) is current. Returns "" when nothing is promoted yet, or the slot was replaced outside the takes flow (e.g. an upload). selFor takes the filename because the slot can depend on it (card slots carry the take's extension).
func Discard ¶ added in v0.9.0
Discard moves a candidate take aside into .cache/discarded/, leaving the bytes intact for Restore. It refuses the promoted take (ErrTakeInUse) and anything that is not a take (ErrNotATake); a take that isn't there is ErrNoTake.
func DiscardedPath ¶ added in v0.9.0
DiscardedPath is where a workspace-relative take is parked while discarded.
func HasCardSelected ¶
HasCardSelected reports whether card has a selected illustration (cards/NN.<any>).
func HasVOSelected ¶
HasVOSelected reports whether line's selected VO take (vo/NN.mp3) exists.
func IsPromoted ¶ added in v0.9.0
IsPromoted reports whether the take is the one currently in its slot, compared by content — the same test the galleries use to mark the current take.
func ListCardTakes ¶
ListCardTakes returns the take filenames for a card (1-based), sorted. A missing takes dir yields an empty list (no takes generated yet).
func ListCoverTakes ¶
ListCoverTakes returns the cover take filenames, sorted (empty if none).
func ListMusicTakes ¶
ListMusicTakes returns the music bed take filenames (music/takes/T.mp3), sorted.
func ListPortraitTakes ¶
ListPortraitTakes returns the portrait take filenames, sorted (empty if none).
func ListVOTakes ¶
ListVOTakes returns a line's VO take filenames (vo/takes/NN-T.mp3), sorted.
func MusicSelected ¶
func MusicTakesDir ¶
func NextCardTake ¶
NextCardTake returns the next take number for a card.
func NextMusicTake ¶
NextMusicTake returns the next bed take number.
func NextVOTake ¶
NextVOTake returns the next take number for a line (1-based).
func ParseCardTake ¶
ParseCardTake extracts the card index, take number, and extension from a card take filename "NN-T.ext" (e.g. "02-3.png" → 2, 3, "png").
func ParseTake ¶
ParseTake extracts the take number + extension from a single-slot take filename "T.ext" (cover/portrait, e.g. "3.png" → 3, "png").
func PortraitSelected ¶
func PortraitTake ¶
PortraitTake / PortraitSelected: portrait/takes/T.<ext> and portrait.png.
func PortraitTakesDir ¶
func Prune ¶
Prune removes the disposable takes dirs and the generation cache (R-WS-22 / `keryx reel prune`); the selected artefacts are untouched.
func Restore ¶ added in v0.9.0
Restore returns a discarded take to its gallery — the undo. A take that was never discarded is ErrNoTake rather than a silent no-op, so a stale undo surfaces instead of pretending to succeed.
func SelectCard ¶
SelectCard promotes cards/takes/NN-T.<ext> to cards/NN.<ext>.
func SelectCover ¶
SelectCover promotes cover/takes/T.png to cover.png.
func SelectMusic ¶
SelectMusic promotes music/takes/T.mp3 to music.mp3.
func SelectPortrait ¶
SelectPortrait promotes portrait/takes/T.png to portrait.png.
func SetCard ¶
SetCard copies an external pre-rendered file into the selected card slot (uploaded media — `keryx cards set`), inferring the extension from src.
func SlotFor ¶ added in v0.9.0
SlotFor maps a workspace-relative TAKE path to the slot path it occupies when promoted, or "" when rel is not a recognised take. One mapping serves every media kind, which is what lets discard have a single implementation.
func VOSelected ¶
func VOTakesDir ¶
VOTakesDir / MusicTakesDir: the dirs holding candidate audio takes.
Types ¶
This section is empty.