cmd

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackendAPI  = backend.BackendAPI
	BackendDB   = backend.BackendDB
	BackendAuto = backend.BackendAuto
)

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

View Source
var (
	Version   = "dev"
	Commit    = "unknown"
	BuildDate = "unknown"
)

These are set via ldflags during build

Functions

func Execute

func Execute(args []string) error

func NewRootCmd

func NewRootCmd() *cobra.Command

func OutputList added in v0.1.7

func OutputList[T any](app *App, ctx context.Context, items []T, emptyMessage string, textFn func(io.Writer, []T)) error

func WithApp added in v0.1.7

func WithApp(ctx context.Context, app *App) context.Context

Types

type App added in v0.1.7

type App struct {
	Config Config
	In     io.Reader
	Out    io.Writer
	Err    io.Writer
	// contains filtered or unexported fields
}

func AppFromContext added in v0.1.7

func AppFromContext(ctx context.Context) *App

func NewApp added in v0.1.7

func NewApp(cmd *cobra.Command, flags *rootFlags) *App

func (*App) AccountIDList added in v0.2.5

func (a *App) AccountIDList() []string

func (*App) AccountParams added in v0.1.7

func (a *App) AccountParams() url.Values

func (*App) AddAccountIDs added in v0.1.7

func (a *App) AddAccountIDs(params url.Values)

func (*App) AgentHandlesEnabled added in v0.2.5

func (a *App) AgentHandlesEnabled(ctx context.Context) bool

func (*App) Backend added in v0.2.0

func (a *App) Backend() string

func (*App) BaseURL added in v0.1.7

func (a *App) BaseURL() string

func (*App) Client added in v0.1.7

func (a *App) Client(ctx context.Context) (*api.Client, error)

func (*App) ColorEnabled added in v0.1.7

func (a *App) ColorEnabled(ctx context.Context) bool

func (*App) Confirm added in v0.1.7

func (a *App) Confirm(prompt string) (bool, error)

func (*App) IsAgentOutput added in v0.2.3

func (a *App) IsAgentOutput(ctx context.Context) bool

func (*App) IsTextLikeOutput added in v0.2.3

func (a *App) IsTextLikeOutput(ctx context.Context) bool

func (*App) IsTextOutput added in v0.1.7

func (a *App) IsTextOutput(ctx context.Context) bool

func (*App) Output added in v0.1.7

func (a *App) Output(ctx context.Context, data any, textFn func(io.Writer)) error

func (*App) OutputEvent added in v0.1.7

func (a *App) OutputEvent(ctx context.Context, data any, textFn func(io.Writer)) error

func (*App) OutputFormat added in v0.1.7

func (a *App) OutputFormat(ctx context.Context) string

func (*App) OutputTextf added in v0.1.7

func (a *App) OutputTextf(ctx context.Context, data any, format string, args ...any) error

func (*App) ProgressWriter added in v0.1.7

func (a *App) ProgressWriter(ctx context.Context) io.Writer

ProgressWriter returns stderr when JSON output is requested to keep stdout clean.

func (*App) ReadBackend added in v0.2.8

func (a *App) ReadBackend() string

ReadBackend returns the preferred backend for read-only operations. Defaults to Auto (tries DB first for speed, falls back to API when needed). Respects --source flag when explicitly set.

func (*App) RecordChatHandles added in v0.2.5

func (a *App) RecordChatHandles(ctx context.Context, chats []api.Chat)

func (*App) RecordContactHandles added in v0.2.5

func (a *App) RecordContactHandles(ctx context.Context, chats []api.Chat)

func (*App) RecordInboxHandles added in v0.2.5

func (a *App) RecordInboxHandles(ctx context.Context, items []domain.InboxItem)

func (*App) RecordMessageHandles added in v0.2.5

func (a *App) RecordMessageHandles(ctx context.Context, messages []api.Message)

func (*App) ResolveAlias added in v0.2.1

func (a *App) ResolveAlias(ctx context.Context, client *api.Client, input string) (string, error)

func (*App) ResolveChatByName added in v0.1.7

func (a *App) ResolveChatByName(ctx context.Context, client *api.Client, name string, opts cli.ChatResolveOptions) (string, error)

func (*App) ResolveChatHandle added in v0.2.5

func (a *App) ResolveChatHandle(ctx context.Context, ref cli.HandleRef) (string, error)

func (*App) ResolveChatIDFromArgOrFlag added in v0.1.7

func (a *App) ResolveChatIDFromArgOrFlag(ctx context.Context, client *api.Client, args []string, name, label string, opts cli.ChatResolveOptions) (string, error)

func (*App) ResolveChatIDFromFlags added in v0.1.7

func (a *App) ResolveChatIDFromFlags(ctx context.Context, client *api.Client, name, chatID, nameFlag, idFlag string, opts cli.ChatResolveOptions) (string, error)

func (*App) ResolveMessageHandle added in v0.2.5

func (a *App) ResolveMessageHandle(ctx context.Context, ref cli.HandleRef) (string, string, error)

func (*App) Table added in v0.1.7

func (a *App) Table(ctx context.Context, w io.Writer, headers []string) *outfmt.TableWriter

type ChatLight added in v0.2.13

type ChatLight struct {
	ID           string    `json:"id"`
	Title        string    `json:"title"`
	Network      string    `json:"network"`
	Type         string    `json:"type"`
	UnreadCount  int       `json:"unreadCount"`
	LastActivity time.Time `json:"lastActivity"`
	Preview      string    `json:"preview,omitempty"`
}

ChatLight is a minimal chat payload for list/search commands.

func ToChatLight added in v0.2.13

func ToChatLight(c api.Chat) ChatLight

ToChatLight converts a full Chat to a light representation.

func ToChatLightSlice added in v0.2.13

func ToChatLightSlice(chats []api.Chat) []ChatLight

ToChatLightSlice converts a slice of full chats to light representations.

type Config added in v0.1.7

type Config struct {
	Account string
	Output  string
	Query   string
	Format  string
	Color   string
	Debug   bool
	BaseURL string
	Profile string
	Source  string
	DBPath  string
	Handles bool
}

type InboxItem added in v0.1.6

type InboxItem = domain.InboxItem

type InboxItemLight added in v0.2.13

type InboxItemLight struct {
	ChatID    string    `json:"chatID"`
	ChatTitle string    `json:"chatTitle"`
	Sender    string    `json:"sender"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
}

InboxItemLight is a minimal inbox item payload.

func ToInboxItemLight added in v0.2.13

func ToInboxItemLight(item domain.InboxItem) InboxItemLight

ToInboxItemLight converts a full InboxItem to a light representation.

func ToInboxItemLightSlice added in v0.2.13

func ToInboxItemLightSlice(items []domain.InboxItem) []InboxItemLight

ToInboxItemLightSlice converts a slice of full inbox items to light representations.

type MessageLight added in v0.2.13

type MessageLight struct {
	ID        string    `json:"id"`
	ChatID    string    `json:"chatID"`
	Sender    string    `json:"sender"`
	Text      string    `json:"text"`
	Timestamp time.Time `json:"timestamp"`
	IsMe      bool      `json:"isMe"`
}

MessageLight is a minimal message payload for list/search commands.

func ToMessageLight added in v0.2.13

func ToMessageLight(m api.Message) MessageLight

ToMessageLight converts a full Message to a light representation.

func ToMessageLightSlice added in v0.2.13

func ToMessageLightSlice(msgs []api.Message) []MessageLight

ToMessageLightSlice converts a slice of full messages to light representations.

Jump to

Keyboard shortcuts

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