Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsQuoted ¶ added in v0.13.0
IsQuoted reports whether the whole string is a single quoted phrase, e.g. `"hello world"`. Gmail matches such a phrase exactly, and it can be used as is in a query without further quoting.
func NeedsQuoting ¶ added in v0.13.0
NeedsQuoting reports whether a string contains characters that Gmail's search syntax would interpret specially, and that therefore need to be escaped with quotes before the string can be used verbatim in a search query.
This is the single source of truth for that decision: callers that need to know upfront whether a value will be quoted (e.g. rimport, when deciding whether a value downloaded from Gmail already carries meaningful raw syntax that must not be re-quoted) must use this same predicate, or risk silently diverging from the actual quoting behavior below.
Types ¶
type Actions ¶
type Actions struct {
AddLabel string
Category gmail.Category
Archive bool
Delete bool
MarkImportant bool
MarkNotImportant bool
MarkRead bool
MarkNotSpam bool
Star bool
Forward string
}
Actions represents an action associated with a Gmail filter.
type Criteria ¶
Criteria represents the filtering criteria associated with a Gmail filter.
func GenerateCriteria ¶
func GenerateCriteria(crit parser.CriteriaAST) (Criteria, error)
GenerateCriteria translates a rule criteria into an entry that maps directly into Gmail filters.
func (Criteria) ToGmailSearch ¶
ToGmailSearch returns the equivalent query in Gmail search syntax.
func (Criteria) ToGmailSearchURL ¶ added in v0.11.0
ToGmailSearchURL returns the equivalent query in an URL to Gmail search.
type Filter ¶
type Filter struct {
// ID is an optional identifier associated with a filter.
ID string
Action Actions
Criteria Criteria
}
Filter matches 1:1 a filter created on Gmail.
func (Filter) DebugString ¶ added in v0.11.0
DebugString returns text representation of the filter with extra debugging information Gmail search representation and URL included.
type Filters ¶
type Filters []Filter
Filters is a list of filters created in Gmail.
func FromRulesWithLimit ¶
FromRulesWithLimit translates rules into entries that map directly into Gmail, but uses a custom size limit.
func (Filters) DebugString ¶ added in v0.11.0
type FiltersDiff ¶
type FiltersDiff struct {
Added Filters
Removed Filters
PrintDebugInfo bool
ContextLines int
Colorize bool
}
FiltersDiff contains filters that have been added and removed locally with respect to upstream.
func Diff ¶
func Diff(upstream, local Filters, debugInfo bool, contextLines int, colorize bool) (FiltersDiff, error)
Diff computes the diff between two lists of filters.
To compute the diff, IDs are ignored, only the contents of the filters are actually considered.
func NewMinimalFiltersDiff ¶
func NewMinimalFiltersDiff(added, removed Filters, printDebugInfo bool, contextLines int, colorize bool) FiltersDiff
NewMinimalFiltersDiff creates a new FiltersDiff with reordered filters, where similar added and removed ones are next to each other.
The algorithm used is a quadratic approximation to the otherwise NP-complete travel salesman problem. Hopefully the number of filters is low enough to make this not too slow and the approximation not too bad.
func (FiltersDiff) Empty ¶
func (f FiltersDiff) Empty() bool
Empty returns true if the diff is empty.
func (FiltersDiff) String ¶
func (f FiltersDiff) String() string