cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 4 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 Execute

func Execute(cmd *cobra.Command) error

Execute resets opted-in flags before Cobra parses arguments. It restores each command's original SilenceErrors setting after execution, even on panic. Passing a child command executes and restores its entire root tree.

func FlagsGetString

func FlagsGetString(flags *pflag.FlagSet, name, defaults string) (out string)

FlagsGetString reads string value from flags and returns it, if error => returns defaults.

func ResetBoolOnExecute

func ResetBoolOnExecute(flag *pflag.Flag, target *bool, defaultValue func() bool)

ResetBoolOnExecute marks a local flag registered with BoolVarP to read its default again before every Execute.

func ResetStringOnExecute

func ResetStringOnExecute(flag *pflag.Flag, target *string, defaultValue func() string)

ResetStringOnExecute marks a local flag registered with StringVarP to read its default again before every Execute.

func ResetStringSliceOnExecute

func ResetStringSliceOnExecute(flag *pflag.Flag, target *[]string, defaultValue func() []string)

ResetStringSliceOnExecute marks a local flag registered with StringSliceVarP to read its defaults again before each Execute.

Types

type Commander

type Commander interface {
	Register() *cobra.Command
}

Commander represents valid cobra.Command command.

type Helper

type Helper struct {
	// UserConfigDir returns user's config directory see also: [os.UserConfigDir]
	UserConfigDir func() (string, error)
}

Helper provides different system functions over one entrypoint (i.e. this helper) You can override functions for testing applicable assets.

func NewHelper

func NewHelper() *Helper

NewHelper creates Helper with system defaults.

func (*Helper) WithUserConfigDir

func (h *Helper) WithUserConfigDir(fnc func() (string, error)) *Helper

WithUserConfigDir sets os.UserConfigDir compatible function for tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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