argsbuilder

package
v1.8.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MergeOverwrite overwrite arg when merging.
	MergeOverwrite = iota
	// MergeAdditive concat argument lists.
	MergeAdditive
	// MergeDenied fail merge if another object has the arg defined.
	MergeDenied
)

Variables

This section is empty.

Functions

func NewDenylistError

func NewDenylistError(s string) error

NewDenylistError returns a DenyListError.

Types

type Args

type Args map[Key]Value

Args represents a set of args.

func (Args) Args

func (a Args) Args() []string

Args implements the ArgsBuilder interface.

func (Args) Contains

func (a Args) Contains(k Key) bool

Contains checks if an arg key exists.

func (Args) Get

func (a Args) Get(k Key) Value

Get returns an args value.

func (Args) Merge

func (a Args) Merge(args Args, setters ...MergeOption) error

Merge implements the ArgsBuilder interface.

func (Args) MustMerge

func (a Args) MustMerge(args Args, setters ...MergeOption)

MustMerge implements the ArgsBuilder interface.

func (Args) Set

func (a Args) Set(k, v Key) ArgsBuilder

Set implements the ArgsBuilder interface.

type ArgsBuilder

type ArgsBuilder interface {
	MustMerge(Args, ...MergeOption)
	Merge(Args, ...MergeOption) error
	Set(string, string) ArgsBuilder
	Args() []string
}

ArgsBuilder defines the requirements to build and manage a set of args.

type DenyListError

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

DenyListError represents an error indicating that an argument was supplied that is not allowed.

func (*DenyListError) Error

func (b *DenyListError) Error() string

Error implements the Error interface.

type Key

type Key = string

Key represents an arg key.

type MergeOption

type MergeOption func(*MergeOptions)

MergeOption optional merge argument setter.

func WithDenyList

func WithDenyList(denyList Args) MergeOption

WithDenyList disable merge for all keys in map.

func WithMergePolicies

func WithMergePolicies(policies MergePolicies) MergeOption

WithMergePolicies set merge policies during merge.

type MergeOptions

type MergeOptions struct {
	Policies MergePolicies
}

MergeOptions provides optional arguments for merge.

type MergePolicies

type MergePolicies map[string]MergePolicy

MergePolicies merge policy map.

type MergePolicy

type MergePolicy int

MergePolicy defines args builder args merging policy.

type Value

type Value = string

Value represents an arg value.

Jump to

Keyboard shortcuts

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