Documentation
¶
Overview ¶
Package postcmd is the posting state machine behind `keryx approve` and `keryx post`/`post all`/`post due` (spec 0002 §3.3, R-POST/R-AUTH). It drives the workspace's social.json (draft → approved → posted), enforces the approval gate and idempotency, and fans out across platforms via the publish seam. The publisher resolver, the enabled-check, the clock, and the filesystem are injected so the whole machine is unit-tested with a fake publisher and no network.
Index ¶
- func FormatLines(results []Result) []string
- func FormatResults(w io.Writer, results []Result)
- type Poster
- func (p Poster) Approve(slug, platform, at string, revoke bool) ([]Result, error)
- func (p Poster) Post(ctx context.Context, slug, platform string, dryRun, force bool) (Result, error)
- func (p Poster) PostAll(ctx context.Context, slug string, dryRun bool) ([]Result, error)
- func (p Poster) PostDue(ctx context.Context, slug string) ([]Result, error)
- func (p Poster) PostSubset(ctx context.Context, slug string, names []string, dryRun bool) ([]Result, error)
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLines ¶ added in v0.5.0
FormatLines renders per-platform outcomes as human lines, sorted by platform — the shared formatter for both the CLI (FormatResults) and the studio post job.
func FormatResults ¶
FormatResults renders per-platform results as text lines.
Types ¶
type Poster ¶
type Poster struct {
FS afero.Fs
Root string // reel-workspace root (e.g. "reels")
// Resolve constructs the publisher for a platform (nil-able adapters are an
// error). Enabled reports `platforms.<name>.enabled`. Now is the clock.
Resolve func(platform string) (publish.Publisher, error)
Enabled func(platform string) bool
// Constraints resolves a platform's posting constraints (config-tunable, R-SOC-5);
// nil falls back to the built-in defaults.
Constraints func(platform social.Platform) social.Constraint
Now func() time.Time
}
Poster carries the injected dependencies for the posting machine.
func New ¶
New builds a Poster wired to the live props: the publish registry (config- resolved), the platform-enabled + constraints config checks, and the wall clock.
func NewFor ¶ added in v0.5.0
NewFor builds a Poster over an explicit filesystem + config + reel root — the studio drives it against the active project (per-project fs/config), the CLI via New. Platform-enabled and constraints resolve from stores.Config; credentials resolve from stores.Accounts when one was opened.
func (Poster) Approve ¶
Approve sets the approval gate for a platform (or "all"): it refuses any platform whose social copy has hard constraint violations (R-POST-10), sets the optional schedule (R-POST-11), and persists. --revoke returns it to draft.
func (Poster) Post ¶
func (p Poster) Post(ctx context.Context, slug, platform string, dryRun, force bool) (Result, error)
Post publishes one platform (R-POST-1..4): refuses unless approved, is a no-op when already posted (unless force), and on success records posted/posted_at/ post_url. dryRun validates without posting.
func (Poster) PostAll ¶
PostAll posts every enabled + approved platform independently, recording each success even if another fails (R-POST-5..8); it returns an error if any failed.
func (Poster) PostDue ¶
PostDue posts the approved platforms whose schedule is due (R-POST-12/13) — the unattended CI entrypoint. Idempotent.
func (Poster) PostSubset ¶ added in v0.5.0
func (p Poster) PostSubset(ctx context.Context, slug string, names []string, dryRun bool) ([]Result, error)
PostSubset posts the named enabled + approved platforms — one load/save, the same per-platform resilience as PostAll (a failure doesn't abort the rest). A named platform that isn't enabled+approved is simply not posted (fanOut skips it).