mail

package
v1.0.38 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mail implements the gro mail command and subcommands.

Index

Constants

This section is empty.

Variables

View Source
var ClientFactory = func(ctx context.Context) (MailClient, error) {
	return gmail.NewClient(ctx)
}

ClientFactory is the function used to create Gmail clients. Override in tests to inject mocks.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the mail parent command with subcommands

func SanitizeFilename added in v1.0.19

func SanitizeFilename(s string) string

SanitizeFilename sanitizes a filename for display, removing potentially dangerous characters while preserving readability.

func SanitizeOutput added in v1.0.19

func SanitizeOutput(s string) string

SanitizeOutput removes ANSI escape sequences and dangerous control characters from a string to prevent terminal injection attacks. Safe whitespace characters (tab, newline, carriage return) are preserved.

Types

type Label

type Label struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	Type           string `json:"type"`
	MessagesTotal  int64  `json:"messagesTotal,omitempty"`
	MessagesUnread int64  `json:"messagesUnread,omitempty"`
}

Label represents a Gmail label for output

type MailClient added in v1.0.35

type MailClient interface {
	GetMessage(ctx context.Context, messageID string, includeBody bool) (*gmail.Message, error)
	SearchMessages(ctx context.Context, query string, maxResults int64) ([]*gmail.Message, int, error)
	SearchMessageIDs(ctx context.Context, query string, maxResults int64) ([]string, error)
	GetThread(ctx context.Context, id string) ([]*gmail.Message, error)
	FetchLabels(ctx context.Context) error
	GetLabelName(labelID string) string
	GetLabelID(ctx context.Context, name string) (string, error)
	GetLabels() []*gmailv1.Label
	ModifyMessages(ctx context.Context, ids []string, addLabels, removeLabels []string) error
	GetAttachments(ctx context.Context, messageID string) ([]*gmail.Attachment, error)
	DownloadAttachment(ctx context.Context, messageID string, attachmentID string) ([]byte, error)
	DownloadInlineAttachment(ctx context.Context, messageID string, partID string) ([]byte, error)
	GetProfile(ctx context.Context) (*gmail.Profile, error)
}

MailClient defines the interface for Gmail client operations used by mail commands.

type MessagePrintOptions

type MessagePrintOptions struct {
	IncludeThreadID bool
	IncludeTo       bool
	IncludeSnippet  bool
	IncludeBody     bool
}

MessagePrintOptions controls which fields to include in message output

Jump to

Keyboard shortcuts

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