appctx

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithApp

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

WithApp stores the App in a context.

Types

type App

type App struct {
	Config *config.Config
	Auth   *auth.Manager
	Output *output.Writer
	Flags  GlobalFlags
	// contains filtered or unexported fields
}

App holds the shared application context for all commands.

func FromContext

func FromContext(ctx context.Context) *App

FromContext retrieves the App from a context.

func NewApp

func NewApp(cfg *config.Config) *App

NewApp creates a new App with config and auth.

func (*App) ApplyFlags

func (a *App) ApplyFlags()

ApplyFlags applies global flag values and config to configure the app. Priority: explicit flags > config file values > defaults.

func (*App) CalDAV

func (a *App) CalDAV() (*caldav.Client, error)

CalDAV returns the CalDAV client, creating it lazily. Requires DAV credentials (App Password); returns ErrDAVNotConfigured when credentials are missing, or the original error for other failures.

func (*App) Err

func (a *App) Err(err error) error

Err outputs a structured error response to stderr AND returns a PrintedError wrapping the original so cobra gets a non-zero exit code while Execute() knows it was already printed.

func (*App) IsInteractive

func (a *App) IsInteractive() bool

IsInteractive returns true if the terminal supports interactive input.

func (*App) IsMachineOutput

func (a *App) IsMachineOutput() bool

IsMachineOutput returns true if output is for automation.

func (*App) JMAP

func (a *App) JMAP() (*jmap.Client, error)

JMAP returns the JMAP client, creating it lazily.

func (*App) OK

func (a *App) OK(data any, opts ...output.ResponseOption) error

OK outputs a success response.

func (*App) WebDAV

func (a *App) WebDAV() (*webdav.Client, error)

WebDAV returns the WebDAV client, creating it lazily. Requires DAV credentials (App Password); returns ErrDAVNotConfigured when credentials are missing, or the original error for other failures.

type GlobalFlags

type GlobalFlags struct {
	JSON     bool
	Quiet    bool
	MD       bool
	Styled   bool
	IDsOnly  bool
	Count    bool
	Agent    bool
	JQFilter string
	Mailbox  string
	Verbose  int
	Stats    bool
	NoStats  bool
	Hints    bool
	NoHints  bool
	CacheDir string
}

GlobalFlags holds values for global CLI flags.

type PrintedError

type PrintedError struct {
	Cause error
}

PrintedError wraps an error that has already been printed to the user.

func (*PrintedError) Error

func (e *PrintedError) Error() string

func (*PrintedError) Unwrap

func (e *PrintedError) Unwrap() error

Jump to

Keyboard shortcuts

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