slice

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SliceFlag

type SliceFlag[T any] struct {
	builder.StaticFlag[[]T]
	// contains filtered or unexported fields
}

SliceFlag is the user‐facing builder for slice flags.

func RegisterSlice

func RegisterSlice[T any](
	reg core.Registry,
	name, usage string,
	val sliceValueProvider[T],
	ptr *[]T,
) *SliceFlag[T]

RegisterSlice registers a slice flag.

func (*SliceFlag[T]) Changed added in v0.0.42

func (f *SliceFlag[T]) Changed() bool

Changed returns true if the value was changed.

func (*SliceFlag[T]) Choices

func (f *SliceFlag[T]) Choices(allowed ...T) *SliceFlag[T]

Choices restricts allowed slice elements.

func (*SliceFlag[T]) Default added in v0.0.42

func (f *SliceFlag[T]) Default() []T

Default returns the default value.

func (*SliceFlag[T]) Delimiter

func (f *SliceFlag[T]) Delimiter(sep string) *SliceFlag[T]

Delimiter sets the delimiter used to split input values.

func (*SliceFlag[T]) Validate

func (f *SliceFlag[T]) Validate(fn func(T) error) *SliceFlag[T]

Validate lets you plug in arbitrary per‐element checks.

type SliceValue

type SliceValue[T any] struct {
	// contains filtered or unexported fields
}

SliceValue implements slice flag parsing and validation.

func NewSliceValue

func NewSliceValue[T any](
	ptr *[]T,
	def []T,
	parse func(string) (T, error),
	format func(T) string,
	delimiter string,
) *SliceValue[T]

NewSliceValue creates a new slice value.

func (*SliceValue[T]) Base

func (v *SliceValue[T]) Base() *SliceValue[T]

Base returns the underlying value.

func (*SliceValue[T]) Changed

func (v *SliceValue[T]) Changed() bool

Changed returns true if the value was changed.

func (*SliceValue[T]) Default

func (f *SliceValue[T]) Default() string

Default returns the default value as string.

func (*SliceValue[T]) Get

func (v *SliceValue[T]) Get() any

Get returns the parsed slice for the given ID.

func (*SliceValue[T]) IsSlice added in v0.0.19

func (v *SliceValue[T]) IsSlice()

isSlice is a no-op marker method to implement core.SliceMarker.

func (*SliceValue[T]) Set

func (v *SliceValue[T]) Set(s string) error

Set parses and stores the slice from a delimited string for a given ID.

Jump to

Keyboard shortcuts

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