flags

package
v0.0.0-...-89aa834 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package flags provides custom flag types and utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string]string

Map is a map of string key-value pairs that implements the flag.Value interface.

func (Map) Contains

func (m Map) Contains(k string) bool

Contains reports whether the key is in the map.

func (Map) Get

func (m Map) Get(k string) string

Get returns the value of the key.

func (Map) IsAllValuesSet

func (m Map) IsAllValuesSet() bool

IsAllValuesSet reports whether all values are set.

func (Map) Lookup

func (m Map) Lookup(k string) (string, bool)

Lookup returns the value of the key and reports whether the key is in the map.

func (*Map) Set

func (m *Map) Set(s string) error

Set implements the flag.Value interface.

func (Map) String

func (m Map) String() string

String implements the flag.Value interface.

type MapSlice

type MapSlice map[string]Slice

MapSlice is a map of string key-slice pairs that implements the flag.Value interface. It is used to parse multiple values for the same key.

func (MapSlice) Contains

func (m MapSlice) Contains(k string) bool

Contains reports whether the key is in the map.

func (MapSlice) Get

func (m MapSlice) Get(k string) Slice

Get returns the slice of the key.

func (MapSlice) Lookup

func (m MapSlice) Lookup(k string) (Slice, bool)

Lookup returns the slice of the key and reports whether the key is in the map.

func (*MapSlice) Set

func (m *MapSlice) Set(s string) error

Set implements the flag.Value interface.

func (MapSlice) String

func (m MapSlice) String() string

type Option

type Option func(*options)

Option is an option for flag types.

func NameColor

func NameColor(c term.Color) Option

NameColor sets the color of command names.

func Newline

func Newline() Option

Newline adds a newline after the usage text.

type Slice

type Slice []string

Slice is a slice of strings that implements the flag.Value interface.

func (*Slice) Set

func (s *Slice) Set(v string) error

Set implements the flag.Value interface.

func (Slice) String

func (s Slice) String() string

String implements the flag.Value interface.

type UsageFunc

type UsageFunc func(usage string) string

UsageFunc is a function that formats usage text.

func UseUsage

func UseUsage(w io.Writer, opts ...Option) UsageFunc

UseUsage returns a UsageFunc that formats usage text with colorized command names.

Jump to

Keyboard shortcuts

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