postcmd

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 17 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLines added in v0.5.0

func FormatLines(results []Result) []string

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

func FormatResults(w io.Writer, results []Result)

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

func New(ctx context.Context, p *props.Props) Poster

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

func NewFor(fs afero.Fs, stores publish.Stores, root string) Poster

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

func (p Poster) Approve(slug, platform, at string, revoke bool) ([]Result, error)

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

func (p Poster) PostAll(ctx context.Context, slug string, dryRun bool) ([]Result, error)

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

func (p Poster) PostDue(ctx context.Context, slug string) ([]Result, error)

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).

type Result

type Result struct {
	Platform string `json:"platform"`
	Status   string `json:"status"` // posted | skipped | failed | dry-run
	URL      string `json:"url,omitempty"`
	Detail   string `json:"detail,omitempty"`
}

Result is one platform's posting outcome (for per-platform reporting / json).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL