Documentation
¶
Index ¶
- Variables
- func BindConfigs(v *viper.Viper, rootCmdName string, opts ...ConfigOption) error
- func DebugViper(v *viper.Viper) string
- func GenConfigRunE(format PrintConfigFormat) func(cmd *cobra.Command, args []string) error
- func GetFlags(cmd *cobra.Command) map[string]any
- func NewRoot(v *viper.Viper) *cobra.Command
- func NewRootWithOption(v *viper.Viper, option RootFlagOption) *cobra.Command
- func OpenOrStdIn(filename string, fs afero.Fs, opts ...OptionFunc) (io.ReadCloser, error)
- func PrintConfig(w io.Writer, m map[string]any, format PrintConfigFormat) error
- func RootPersistentPreRunE(cmd *cobra.Command, v *viper.Viper, _ afero.Fs, _ []string) error
- func SetLogger(l *slog.Logger)
- func SnakeToKebab(f *pflag.FlagSet, name string) pflag.NormalizedName
- func VerbosityLevel(v *viper.Viper, opts ...VerbosityLevelOption) slog.Level
- func VersionFunc(version, commit, date string) string
- func WithManualInputEnabled(o *Option)
- type ConfigOption
- func WithConfigFileFlag(cmd *cobra.Command, flagName string) ConfigOption
- func WithConfigFileName(file string) ConfigOption
- func WithConfigFilePaths(paths ...string) ConfigOption
- func WithMergeConfig(merge bool) ConfigOption
- func WithOverrideBy(key string) ConfigOption
- func WithOverrideDisabled() ConfigOption
- type ConfigOptions
- type FlagOption
- type Option
- type OptionFunc
- type PrintConfigFormat
- type RootFlagOption
- type VerbosityLevelOption
- type VerbosityLevelOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultRootFlagOption = RootFlagOption{ Version: FlagOption{Name: "version", Shorthand: "V", Usage: "Print version information and quit"}, Config: FlagOption{Name: "config", Shorthand: "", Usage: "configuration `filename`"}, NoColor: FlagOption{Name: "no-color", Shorthand: "", Usage: "disable colorized output"}, Verbose: FlagOption{Name: "verbose", Shorthand: "v", Usage: "More output per occurrence. (e.g. -vvv)"}, Quiet: FlagOption{Name: "quiet", Shorthand: "q", Usage: "Silence all output"}, }
View Source
var ErrNoFileSpecified = errors.New("no file specified")
Functions ¶
func BindConfigs ¶ added in v0.3.0
func BindConfigs(v *viper.Viper, rootCmdName string, opts ...ConfigOption) error
func DebugViper ¶ added in v0.1.0
func GenConfigRunE ¶ added in v0.5.1
func GenConfigRunE(format PrintConfigFormat) func(cmd *cobra.Command, args []string) error
func NewRoot ¶ added in v0.1.2
NewRoot returns the base command used when called without any subcommands
func NewRootWithOption ¶ added in v0.1.3
func NewRootWithOption(v *viper.Viper, option RootFlagOption) *cobra.Command
NewRootWithOption returns the base command used when called without any subcommands
func OpenOrStdIn ¶ added in v0.1.0
func OpenOrStdIn(filename string, fs afero.Fs, opts ...OptionFunc) (io.ReadCloser, error)
func PrintConfig ¶ added in v0.5.0
func RootPersistentPreRunE ¶ added in v0.1.2
func SnakeToKebab ¶ added in v0.1.5
func SnakeToKebab(f *pflag.FlagSet, name string) pflag.NormalizedName
SnakeToKebab normalizes flag names from snake_case to kebab-case.
func VerbosityLevel ¶ added in v0.1.2
func VerbosityLevel(v *viper.Viper, opts ...VerbosityLevelOption) slog.Level
func VersionFunc ¶ added in v0.1.0
VersionFunc returns the version string. https://goreleaser.com/cookbooks/using-main.version/
func WithManualInputEnabled ¶ added in v0.2.0
func WithManualInputEnabled(o *Option)
Types ¶
type ConfigOption ¶ added in v0.1.1
type ConfigOption func(*ConfigOptions)
func WithConfigFileFlag ¶ added in v0.3.0
func WithConfigFileFlag(cmd *cobra.Command, flagName string) ConfigOption
func WithConfigFileName ¶ added in v0.3.0
func WithConfigFileName(file string) ConfigOption
func WithConfigFilePaths ¶ added in v0.3.0
func WithConfigFilePaths(paths ...string) ConfigOption
func WithMergeConfig ¶ added in v0.3.0
func WithMergeConfig(merge bool) ConfigOption
func WithOverrideBy ¶ added in v0.3.0
func WithOverrideBy(key string) ConfigOption
func WithOverrideDisabled ¶ added in v0.3.0
func WithOverrideDisabled() ConfigOption
type ConfigOptions ¶ added in v0.3.0
type ConfigOptions struct {
// contains filtered or unexported fields
}
type FlagOption ¶ added in v0.1.3
type OptionFunc ¶ added in v0.2.0
type OptionFunc func(*Option)
func WithStdin ¶ added in v0.2.0
func WithStdin(stdin io.Reader) OptionFunc
type PrintConfigFormat ¶ added in v0.5.0
type PrintConfigFormat int
const ( YAML PrintConfigFormat = iota TOML JSON )
type RootFlagOption ¶ added in v0.1.3
type RootFlagOption struct { Version FlagOption Config FlagOption NoColor FlagOption Verbose FlagOption Quiet FlagOption }
type VerbosityLevelOption ¶ added in v0.5.0
type VerbosityLevelOption func(*VerbosityLevelOptions)
func WithQuietName ¶ added in v0.5.0
func WithQuietName(quietName string) VerbosityLevelOption
func WithVerbosityName ¶ added in v0.5.0
func WithVerbosityName(verboseName string) VerbosityLevelOption
func WithVerbosityStep ¶ added in v0.5.0
func WithVerbosityStep(step int) VerbosityLevelOption
func WithVerbosityZeroLevel ¶ added in v0.5.0
func WithVerbosityZeroLevel(level slog.Level) VerbosityLevelOption
type VerbosityLevelOptions ¶ added in v0.5.0
type VerbosityLevelOptions struct {
// contains filtered or unexported fields
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.