flags

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBoolFlag

func AddBoolFlag(
	cmd *cobra.Command,
	f Flag[bool],
) *bool

Adds the given boolean-valued flag to the given command.

func AddStringFlag

func AddStringFlag(
	cmd *cobra.Command,
	f Flag[string],
) *string

Adds the given string-valued flag to the given command.

func AddStringSliceFlag

func AddStringSliceFlag(
	cmd *cobra.Command,
	f Flag[[]string],
) *[]string

Adds the given string-slice-valued flag to the given command.

Types

type Flag

type Flag[T any] struct {
	// Whether this flag is inherited by subcommands.
	Persistent bool

	Name         string
	ShortName    optionals.Optional[rune]
	DefaultValue T
	UsageMsg     string

	Required       bool
	Hidden         bool
	DeprecationMsg optionals.Optional[string]

	// If given, then command-line completions will be restricted to filenames
	// having any of the given extensions.
	FilenameExts optionals.Optional[[]string]

	// Whether command-line completions should be restricted to directory names.
	DirNames bool
}

Defines a command-line Flag.

Jump to

Keyboard shortcuts

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