tag

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tag parses and evaluates the --tag marker filter. A marker carries its own labels (tags=prod,ci); a filter built from one or more --tag values decides which markers a run touches. Within a single --tag value, "/" separates OR alternatives and "," separates AND requirements, and a "!" prefix excludes a tag; repeated values accumulate. The filter is pure and the rendering is human-readable, so the CLI can log exactly what it will act on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	All []string
	Any []string
	Not []string
}

Filter selects markers by tag. A marker matches when it carries none of Not (exclusions veto), every tag in All (AND), and at least one tag in Any (OR). An empty list drops that requirement, so the zero Filter matches everything. Matching is case-insensitive.

func Parse

func Parse(values []string) (Filter, error)

Parse builds a Filter from raw --tag values. A value containing "/" splits on it into OR alternatives; any other value splits on "," into AND requirements. A term prefixed with "!" is an exclusion, collected regardless of separator. Surrounding whitespace is trimmed and empty items dropped; repeated flags accumulate, so --tag a,b --tag c/d yields All=[a b], Any=[c d].

Mixing "," and "/" in a single value is ambiguous (AND-vs-OR precedence) and is rejected, rather than silently producing an unmatchable term; combine an AND set and an OR set by passing them as separate --tag values instead.

func (Filter) Empty

func (f Filter) Empty() bool

Empty reports whether the filter constrains nothing, in which case every marker matches.

func (Filter) Match

func (f Filter) Match(tags []string) bool

Match reports whether a marker carrying tags satisfies the filter. An empty filter matches everything. An exclusion vetoes a marker carrying that tag; an include requirement (All/Any) is never satisfied by an untagged marker, so a filter with includes targets exactly the tagged markers, while a pure-exclusion filter keeps everything except the excluded.

func (Filter) String

func (f Filter) String() string

String renders the filter as a boolean expression, e.g. "prod AND ci", "eu OR us", "(prod AND ci) AND (eu OR us)", or "prod AND NOT legacy". The zero Filter renders empty.

Jump to

Keyboard shortcuts

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