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 ¶
- func Adopt(ctx context.Context, w io.Writer, in io.Reader, ports AdoptPorts, ...) error
- func ReadLine(in io.Reader) string
- func Remove(ctx context.Context, w io.Writer, store sessions.StateStore, args []string) error
- func Sessions(ctx context.Context, w io.Writer, store Store) error
- func Stats(ctx context.Context, w io.Writer, store Store, project session.Project, ...) error
- func Status(ctx context.Context, w io.Writer, store Store, read StatusReader) error
- type AdoptPorts
- type PRLister
- type StatusReader
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Adopt ¶
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 ¶
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 ¶
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 ¶
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)
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 ¶
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.