cobrautil

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MPL-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfigFileForEachCommand added in v1.1.0

func AddConfigFileForEachCommand(cmd *cobra.Command, g templates.FlagGroups, configFileFlagName string)

func BindAll

func BindAll(cmd *cobra.Command, envPrefix, configFileFlagName string, opts ...ViperOpt) error

BindAll updates the given command flags with values from the environment variables and config file. The supported formats are: JSON, YAML, TOML, HCL, and Java properties. The file format is determined by the file extension, if not specified the default format is YAML. The following precedence order of configuration sources is used: command flags, environment variables, config file, default values.

func BindFromViper added in v1.1.0

func BindFromViper(cmd *cobra.Command, v *viper.Viper) error

BindFromViper updates the given command flags with values from preconditioned Viper instance.

func FullCommandName added in v1.1.0

func FullCommandName(cmd *cobra.Command) string

FullCommandName returns the full name of the command from the root command.

func FullCommandNameTitle added in v1.1.0

func FullCommandNameTitle(cmd *cobra.Command) string

FullCommandNameTitle returns the full name of the command from the root command with the first letter of each word capitalized.

func WriteConfigFile added in v1.1.0

func WriteConfigFile(w io.Writer, g templates.FlagGroups, configFileFlagName string, fs *pflag.FlagSet)

func WriteMarkdownDoc added in v1.1.0

func WriteMarkdownDoc(w io.Writer, g templates.FlagGroups, envPrefix string, cmd *cobra.Command)

Types

type DescribeFormat added in v1.1.0

type DescribeFormat int
const (
	Plain DescribeFormat = iota
	JSON
	YAML
	OneLine
)

type FlagsDescriber added in v1.1.0

type FlagsDescriber struct {
	Format          DescribeFormat
	Unredacted      bool
	ShowChangedOnly bool
	ShowHidden      bool
}

func (FlagsDescriber) DescribeFlags added in v1.1.0

func (d FlagsDescriber) DescribeFlags(fs *pflag.FlagSet) ([]byte, error)

func (FlagsDescriber) DescribeFlagsToMap added in v1.5.0

func (d FlagsDescriber) DescribeFlagsToMap(fs *pflag.FlagSet) map[string]any

type ViperOpt added in v1.3.2

type ViperOpt func(*viper.Viper)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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