cli

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cli is omatty's second driving adapter (ADR 0001, "The second driving adapter"; migration step 7.1, #653): one-shot reads through the same services the TUI uses, written as JSON for a script. It exists to prove the rule as much as to be used - it compiles and passes with no bubbletea in its import graph, so the core is UI-free. The JSON shape is not frozen below 1.0, like state.json and the key table.

err := cli.Sessions(ctx, os.Stdout, store)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adopt

func Adopt(ctx context.Context, w io.Writer, in io.Reader, ports AdoptPorts, args []string) error

Adopt lists the claude sessions in one registered project that omatty does not yet hold, and registers the ones the operator picks. The CLI twin of the ctrl+o A picker, and the sibling of discover: one finds repositories, this finds sessions inside one (#122).

git is a port rather than built here so the flow is testable without a real repository; everything else follows discover exactly.

err := cli.Adopt(ctx, os.Stdout, os.Stdin, ports, []string{"my-app"})

func ReadLine

func ReadLine(in io.Reader) string

ReadLine reads the operator's answer. An unreadable stdin means no answer, which is the same as choosing nothing - and so does a blank line, so the error needs no branch of its own: TrimSpace gives "" for both.

picked := cli.ReadLine(os.Stdin)

func Remove

func Remove(ctx context.Context, w io.Writer, store sessions.StateStore, args []string) error

Remove is `omatty rm <project>`: the CLI twin of ctrl+o x on an empty project's header, and the one surface that needs no cursor (#159).

err := cli.Remove(ctx, os.Stdout, store, []string{"my-app"})

func Sessions

func Sessions(ctx context.Context, w io.Writer, store Store) error

Sessions writes every registered session as a JSON array.

err := cli.Sessions(ctx, os.Stdout, store)

func Stats

func Stats(ctx context.Context, w io.Writer, store Store, project session.Project, prs PRLister) error

Stats is the --stats branch of `omatty gate`: project's lead time and first-pass gate rate, written to w. Kept out of cmd's gateCommand so that command stays a list of flag arms (migration step 7.2, #653).

prs is the forge reader, the TUI's own Router's ListPRs, so a project named in [forge.hosts] gets its lead time here too (#452). A machine without the forge's tool gets no lead time and the gate rate still prints.

err := cli.Stats(ctx, os.Stdout, store, project, router.ListPRs)

func Status

func Status(ctx context.Context, w io.Writer, store Store, read StatusReader) error

Status writes every session's status, as read reports it, as a JSON array. A session with no status yet reads idle, as its card does.

err := cli.Status(ctx, os.Stdout, store, read)

Types

type AdoptPorts

type AdoptPorts struct {
	Store sessions.StateStore
	// Git says which repository a transcript's directory belongs to.
	Git discovery.Git
	// Branches says which branch an adopted session is on.
	Branches sessions.SessionBrancher
	// TranscriptsDir is claude's transcript store, where the sessions are found.
	TranscriptsDir string
	// Prompts is the agent's reading of a typed prompt, which titles each row.
	Prompts discovery.PromptText
}

AdoptPorts is what adopt reads and writes through.

type PRLister

type PRLister func(repoRoot string) ([]forge.PR, error)

PRLister is what Stats needs of the forge, so the command can be tested without one. cmd passes the forge Router's ListPRs.

type StatusReader

type StatusReader func(sess session.Session) status.SessionState

StatusReader is a session's state as its transcript implies, read once. cmd builds it from service/status's Read over infra/transcript's reader.

type Store

type Store interface {
	Load(ctx context.Context) (session.State, error)
}

Store is the slice of the session service's StateStore these reads need.

Jump to

Keyboard shortcuts

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