flags

package
v12.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package flags provides helper methods for working with Cobra flags in a way where Go's usage checker (which produces compilation errors for unused variables) enforces that the programmer didn't forget to define or read the flag.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(name, short, desc string, persistent FlagType) (AddFunc, ReadBoolFlagFunc)

Bool provides mistake-safe access to boolean Cobra command-line flags.

func DryRun

func DryRun() (AddFunc, ReadBoolFlagFunc)

DryRun provides mistake-safe access to the "--dry-run" Cobra command-line flag.

func String

func String(name, short, defaultValue, desc string) (AddFunc, ReadStringFlagFunc)

Bool provides mistake-safe access to string Cobra command-line flags.

func Verbose

func Verbose() (AddFunc, ReadBoolFlagFunc)

Verbose provides mistake-safe access to the "--verbose" Cobra command-line flag.

func Version

func Version() (AddFunc, ReadBoolFlagFunc)

Types

type AddFunc

type AddFunc func(*cobra.Command)

AddFunc defines the type signature for helper functions that add a CLI flag to a Cobra command.

type FlagType

type FlagType int
const (
	FlagTypePersistent FlagType = iota
	FlagTypeNonPersistent
)

type ReadBoolFlagFunc

type ReadBoolFlagFunc func(*cobra.Command) bool

ReadBoolFlagFunc defines the type signature for helper functions that provide the value a boolean CLI flag associated with a Cobra command.

type ReadStringFlagFunc

type ReadStringFlagFunc func(*cobra.Command) string

ReadStringFlagFunc defines the type signature for helper functions that provide the value a string CLI flag associated with a Cobra command.

Jump to

Keyboard shortcuts

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