Documentation
¶
Index ¶
- Constants
- Variables
- func Execute(args []string) error
- func NewRootCmd() *cobra.Command
- func OutputList[T any](app *App, ctx context.Context, items []T, emptyMessage string, ...) error
- func WithApp(ctx context.Context, app *App) context.Context
- type App
- func (a *App) AccountParams() url.Values
- func (a *App) AddAccountIDs(params url.Values)
- func (a *App) Backend() string
- func (a *App) BaseURL() string
- func (a *App) Client(ctx context.Context) (*api.Client, error)
- func (a *App) ColorEnabled(ctx context.Context) bool
- func (a *App) Confirm(prompt string) (bool, error)
- func (a *App) IsTextOutput(ctx context.Context) bool
- func (a *App) Output(ctx context.Context, data any, textFn func(io.Writer)) error
- func (a *App) OutputEvent(ctx context.Context, data any, textFn func(io.Writer)) error
- func (a *App) OutputFormat(ctx context.Context) string
- func (a *App) OutputTextf(ctx context.Context, data any, format string, args ...any) error
- func (a *App) ProgressWriter(ctx context.Context) io.Writer
- func (a *App) ResolveChatByName(ctx context.Context, client *api.Client, name string, ...) (string, error)
- func (a *App) ResolveChatIDFromArgOrFlag(ctx context.Context, client *api.Client, args []string, name, label string, ...) (string, error)
- func (a *App) ResolveChatIDFromFlags(ctx context.Context, client *api.Client, name, chatID, nameFlag, idFlag string, ...) (string, error)
- func (a *App) Table(ctx context.Context, w io.Writer, headers []string) *outfmt.TableWriter
- type Config
- type FallbackEvent
- type FallbackOptions
- type FallbackResult
- type InboxItem
Constants ¶
const ( BackendAPI = "api" BackendDB = "db" BackendAuto = "auto" )
Backend mode constants define how commands fetch data.
BackendAPI: Commands fetch data exclusively from the Beeper Desktop API. If the API is unavailable, commands fail with an error.
BackendDB: Commands fetch data exclusively from the local SQLite database. This mode works offline but data may be stale (last synced when Beeper Desktop was running). Some features are not available in DB mode (pagination, muted/pinned filters, etc.).
BackendAuto (default): Commands try the API first, then automatically fall back to the local database if:
- The API client cannot be created (network issues, API unavailable)
- The API call returns an error
- The API returns empty results
Fallback only occurs when the query can be satisfied by the DB. Commands with API-only features (pagination cursor, direction, inbox filter, etc.) disable fallback automatically.
When fallback occurs, a message is printed to stderr indicating the reason and that DB data is being used. If WarnStale is enabled on the FallbackOptions, an additional warning notes that data may be stale.
Variables ¶
var ( Version = "dev" Commit = "unknown" BuildDate = "unknown" )
These are set via ldflags during build
Functions ¶
func NewRootCmd ¶
func OutputList ¶ added in v0.1.7
Types ¶
type App ¶ added in v0.1.7
func AppFromContext ¶ added in v0.1.7
func (*App) AccountParams ¶ added in v0.1.7
func (*App) AddAccountIDs ¶ added in v0.1.7
func (*App) OutputEvent ¶ added in v0.1.7
func (*App) OutputTextf ¶ added in v0.1.7
func (*App) ProgressWriter ¶ added in v0.1.7
ProgressWriter returns stderr when JSON output is requested to keep stdout clean.
func (*App) ResolveChatByName ¶ added in v0.1.7
func (*App) ResolveChatIDFromArgOrFlag ¶ added in v0.1.7
func (*App) ResolveChatIDFromFlags ¶ added in v0.1.7
type FallbackEvent ¶ added in v0.2.0
type FallbackEvent struct {
Reason string // "api_error", "api_empty", "api_unavailable"
Entity string // "messages", "chats", etc.
Timestamp time.Time
Error error // original error if any
}
FallbackEvent contains structured information about a fallback occurrence.
type FallbackOptions ¶ added in v0.2.0
type FallbackOptions[T any] struct { // Backend is the selected backend mode (api, db, auto) Backend string // FallbackAllowed indicates if fallback is permitted for this operation FallbackAllowed bool // ProgressWriter receives fallback status messages ProgressWriter io.Writer // PreAPIError is an error that occurred before API call (e.g., client creation failed) // If set and fallback is allowed, DB fallback is attempted without calling APICall PreAPIError error // APICall executes the API operation APICall func() (T, error) // DBCall executes the DB operation DBCall func(store *db.Store) (T, error) // IsEmpty checks if the result should trigger fallback IsEmpty func(T) bool // OpenStore opens a DB connection OpenStore func() (*db.Store, error) // EntityName is used in progress messages (e.g., "messages", "chats") EntityName string // OnFallback is called when fallback is triggered (for metrics/logging) OnFallback func(FallbackEvent) // WarnStale adds a warning that DB data may be stale when fallback is used WarnStale bool }
FallbackOptions configures the withFallback behavior.
type FallbackResult ¶ added in v0.2.0
FallbackResult wraps a result with metadata about whether fallback was used.
func (FallbackResult[T]) IsEmpty ¶ added in v0.2.0
func (r FallbackResult[T]) IsEmpty() bool
IsEmpty returns true if the underlying data is empty. Works with slices by checking length via reflection.
type InboxItem ¶ added in v0.1.6
type InboxItem struct {
ChatID string `json:"chatID"`
ChatTitle string `json:"chatTitle"`
Network string `json:"network"`
ChatType string `json:"chatType"`
Message string `json:"message"`
Sender string `json:"sender"`
Timestamp time.Time `json:"timestamp"`
}
InboxItem represents an unread message with chat context
Source Files
¶
- accounts.go
- app.go
- auth.go
- backend.go
- chats.go
- chats_db.go
- client.go
- completion.go
- completions.go
- config.go
- contacts.go
- contacts_db.go
- db_helpers.go
- fallback.go
- filters.go
- focus.go
- inbox.go
- inbox_db.go
- limits.go
- messages.go
- messages_db.go
- output.go
- output_messages.go
- profiles.go
- reminders.go
- root.go
- time_parse.go
- validate.go
- version.go