cli

package
v0.27.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: CC0-1.0 Imports: 51 Imported by: 0

Documentation

Overview

Package cli wires up the prosa CLI: cobra command tree, persistent flags, and the dispatcher for sub-commands. Rendering lives in internal/cli/render; long-running progress in internal/cli/spinner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute() int

Execute is the entry point invoked by cmd/prosa/main.go. It returns the process exit code (0 on success, 1 on error).

func IsInteractive

func IsInteractive() bool

IsInteractive reports whether both stdout and stderr are attached to a TTY. Bubble Tea and color rendering disable themselves when either is piped or redirected — common in cron/LaunchAgent invocations where otherwise we'd emit ANSI escape garbage into log files.

func ParseBetween

func ParseBetween(s string) (time.Time, time.Time, error)

ParseBetween parses "YYYY-MM-DD..YYYY-MM-DD" into an inclusive UTC range. End is the last nanosecond of the second day; end must be >= start.

func ParseLast

func ParseLast(s string) (time.Duration, error)

ParseLast parses window strings like "7d", "12h", "45m". Days ("7d") are handled here because time.ParseDuration doesn't understand them.

func ParseSince

func ParseSince(s string) (time.Time, error)

ParseSince parses a YYYY-MM-DD date in UTC as the start of the day.

func TerminalWidth

func TerminalWidth() int

TerminalWidth returns the current stdout width, falling back to the design baseline when stdout is not attached to a terminal.

func WindowDescriptor

func WindowDescriptor(w Window) string

WindowDescriptor returns a phrase for empty-state messages ("no sessions <X>").

Types

type Match

type Match struct {
	Remote string
	Marker string
	Path   string
	Found  bool
}

Match is the resolved auto-filter target. Exactly one of Remote/Marker/Path is populated; callers use that to choose which SessionFilter dimension to set. When none matches, Found is false.

func DetectProject

func DetectProject(ctx context.Context, cwd string, s *store.Store) (Match, error)

DetectProject resolves the project for timeline auto-filtering per INTENT §5: git remote → .prosa.yaml marker → longest project_path ancestor. Returns Match{Found: false} when nothing matches.

func (Match) HintLabel

func (m Match) HintLabel() string

HintLabel returns a short human label for the context-line status hint: remotes collapse to "owner/repo", paths abbreviate $HOME to ~.

type ProjectScope

type ProjectScope struct {
	Scope   render.ContextScope
	Label   string
	Project string
	Match   Match
}

ProjectScope is the resolved project scope for read commands.

func ResolveProjectScope

func ResolveProjectScope(ctx context.Context, flags globalFlags, s *store.Store) ProjectScope

func ResolveProjectScopeFromLocalStore

func ResolveProjectScopeFromLocalStore(ctx context.Context, flags globalFlags) ProjectScope

func (ProjectScope) ApplyListRequest

func (s ProjectScope) ApplyListRequest(req *prosav1.ListRequest)

func (ProjectScope) ApplyReportRequest

func (s ProjectScope) ApplyReportRequest(req *prosav1.GetReportRequest)

func (ProjectScope) ApplySearchRequest

func (s ProjectScope) ApplySearchRequest(req *prosav1.SearchRequest)

func (ProjectScope) ApplySessionFilter

func (s ProjectScope) ApplySessionFilter(filter *store.SessionFilter)

type Window

type Window struct {
	Since, Until time.Time
	LastLabel    string // "7d" — non-empty iff window came from --last
	SinceLabel   string // "2026-01-01" — non-empty iff --since
	BetweenLabel string // "2026-01-01 and 2026-03-15" — non-empty iff --between
	HeatmapLabel string // "53 weeks" — non-empty iff the fixed heatmap window
}

Window is the resolved time range for a query plus the descriptor labels the renderer uses to assemble the context line. Exactly one of LastLabel / SinceLabel / BetweenLabel / HeatmapLabel is non-empty after a successful ResolveWindow or HeatmapWindow.

func HeatmapWindow

func HeatmapWindow(now time.Time) Window

HeatmapWindow returns the fixed 53-week trailing window aligned to Sunday in UTC. Canonical spec: docs/panel/screens.md (heatmap).

func ResolveWindow

func ResolveWindow(cmd *cobra.Command, last, since, between string, now time.Time) (Window, error)

ResolveWindow resolves the time window from exactly one of --last / --since / --between. --last is "active" only when explicitly set (Cobra Changed check), so the default "7d" doesn't shadow --since or --between.

func (Window) LastSegment

func (w Window) LastSegment() string

LastSegment returns the label for the "last X" context line tail, collapsing LastLabel and HeatmapLabel so call sites don't branch.

Directories

Path Synopsis
Package browser opens URLs in the system default browser.
Package browser opens URLs in the system default browser.
Package render formats the prosa timeline for both interactive terminals (Lipgloss colors, day-grouped headers, active markers) and non-interactive sinks (pipes/redirects/scripts — plain tab-separated rows without escape codes).
Package render formats the prosa timeline for both interactive terminals (Lipgloss colors, day-grouped headers, active markers) and non-interactive sinks (pipes/redirects/scripts — plain tab-separated rows without escape codes).
Package rpc loads the saved auth.json and constructs Connect clients that automatically attach the Bearer token.
Package rpc loads the saved auth.json and constructs Connect clients that automatically attach the Bearer token.
Package schedule installs and removes the prosa-sync background job using the OS-native scheduler: launchd on macOS, systemd user timers on Linux.
Package schedule installs and removes the prosa-sync background job using the OS-native scheduler: launchd on macOS, systemd user timers on Linux.
Package spinner provides a Bubble Tea progress display for `prosa sync`.
Package spinner provides a Bubble Tea progress display for `prosa sync`.

Jump to

Keyboard shortcuts

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