tty

package
v0.0.87 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStatusLines

func FormatStatusLines(info *UsageInfo) string

FormatStatusLines returns the canonical three-line CLI output for status info.

Types

type Options

type Options struct {
	Debug bool
	// Command overrides CODEX_SHOW_STATUS_COMMAND (fake TUI hook for tests).
	Command string
	// SessionID overrides CODEX_SHOW_STATUS_SESSION_ID.
	SessionID string
	// TimeoutSeconds overrides CODEX_SHOW_STATUS_TIMEOUT when > 0.
	TimeoutSeconds int
	// TTYWatchHome overrides TTY_WATCH_HOME.
	TTYWatchHome string
}

Options configures FetchStatusWithOptions. Env fields (Command, SessionID, TimeoutSeconds, TTYWatchHome) override the corresponding process env vars when non-zero/non-empty so callers and tests need not mutate global environment under t.Parallel().

type UsageInfo

type UsageInfo struct {
	MonthlyUsage string
	CreditsUsed  string
	CreditsTotal string
	NextReset    string
}

UsageInfo holds parsed Codex /status output.

func FetchStatus

func FetchStatus(ctx context.Context) (*UsageInfo, error)

FetchStatus launches Codex in an ephemeral ttywatch session and parses /status output.

func FetchStatusWithOptions

func FetchStatusWithOptions(ctx context.Context, opts Options) (*UsageInfo, error)

FetchStatusWithOptions launches Codex with optional verbose logging.

func ParseStatusSnapshot

func ParseStatusSnapshot(stdout string) (*UsageInfo, error)

ParseStatusSnapshot extracts monthly usage, credits, and reset from tty-watch snapshot text.

Jump to

Keyboard shortcuts

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