mflag

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package mflag provides utility functions for pairing matcher.Matcher functions with a pflag.FlagSet. The provided functions exist only to have a uniform and unified call-site for declaring a flag with an associated matcher.Matcher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagSet

type FlagSet struct {
	// contains filtered or unexported fields
}

FlagSet pairs a pflag.FlagSet with a number of matcher.Matcher instances (including negative matcher.Matcher instances). A series of individual flags can be defined, and then an aggregate matcher can be composed based on their provided values at runtime.

func NewMatcherFlags

func NewMatcherFlags(flags *pflag.FlagSet) *FlagSet

NewMatcherFlags returns a new FlagSet bound to the provided pflag.FlagSet.

func (*FlagSet) BoolMatcher

func (m *FlagSet) BoolMatcher(callback func() matcher.Matcher, name string, usage string)

BoolMatcher creates a named bool flag paired with the given matcher.Matcher constructor.

func (*FlagSet) Matcher

func (m *FlagSet) Matcher() (matcher.Matcher, error)

Matcher returns a composed matcher.Matcher derived from each defined flag and their runtime value(s).

func (*FlagSet) StringMatcher added in v0.4.0

func (m *FlagSet) StringMatcher(callback func(string) (matcher.Matcher, error), name string, usage string)

StringMatcher creates a named string flag paired with the given matcher.Matcher constructor (which can return an error).

func (*FlagSet) StringSliceMatcher

func (m *FlagSet) StringSliceMatcher(callback func(string) (matcher.Matcher, error), name string, usage string)

StringSliceMatcher creates a named string slice flag paired with the given matcher.Matcher constructor (which can return an error).

Jump to

Keyboard shortcuts

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