config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func ApplyLogFlags

func ApplyLogFlags(app *cobra.Command)

func CompletionCommand

func CompletionCommand() *cobra.Command

func DefaultCLI

func DefaultCLI(app *cobra.Command, version, commit, envPrefix string)

func EnvironmentConfig

func EnvironmentConfig(envPrefix string)

func One

func One() cobra.PositionalArgs

func Range

func Range(min, max int) cobra.PositionalArgs

func VersionCommand

func VersionCommand(version, commit string) *cobra.Command

Types

type Applicant

type Applicant func(builder *Command)

func Alias

func Alias(aliases ...string) Applicant

func Args

func Completion

func Completion() Applicant

func Deprecated

func Deprecated(message string) Applicant

func Flag

func Flag(name string, flagType FlagType, options ...FlagOption) Applicant

func FlagLogFile

func FlagLogFile() Applicant

func FlagLogFormat

func FlagLogFormat() Applicant

func FlagLogLevel

func FlagLogLevel(level string) Applicant

func FlagLogLevelA added in v0.6.0

func FlagLogLevelA(level string) Applicant

func Hidden

func Hidden() Applicant

func Long

func Long(description string) Applicant

func Run

func Run(fn func(cmd *cobra.Command, args []string)) Applicant

func Short

func Short(description string) Applicant

func SubCommand

func SubCommand(name string, applicants ...Applicant) Applicant

func ValidArgs

func ValidArgs(args ...string) Applicant

func Version

func Version(version, commit string) Applicant

func WrapBuilderOption

func WrapBuilderOption(fn ...CommandOption) Applicant

type Command

type Command struct {
	// contains filtered or unexported fields
}

func NewCommandline

func NewCommandline(name string, applicants ...Applicant) *Command

func (*Command) A

func (s *Command) A(fn func(c *Command)) *Command

func (*Command) Apply

func (s *Command) Apply(applicants ...Applicant) *Command

func (*Command) Debug

func (s *Command) Debug(w io.StringWriter)

func (*Command) Execute added in v0.7.0

func (s *Command) Execute() error

func (*Command) ExecuteOrPanic added in v0.7.0

func (s *Command) ExecuteOrPanic()

func (*Command) GenerateCobra

func (s *Command) GenerateCobra() *cobra.Command

func (*Command) S

func (s *Command) S(name string, opts ...Applicant) *Command

func (*Command) Sub

func (s *Command) Sub(name string, applicants ...Applicant) *Command

type CommandOption

type CommandOption func(cmd *cobra.Command)

type FlagInfo

type FlagInfo struct {
	// contains filtered or unexported fields
}

type FlagOption

type FlagOption func(fi *FlagInfo)

func Abbr

func Abbr(char string) FlagOption

func Description

func Description(desc string) FlagOption

func Dirname added in v0.4.0

func Dirname() FlagOption

func Env

func Env() FlagOption

Env option allows this Flag to be set from the environment. Please note that the name of the Flag is converted to snake_case. For more control over the name use EnvName.

func EnvName

func EnvName(name string) FlagOption

func Filename added in v0.4.0

func Filename(extensions ...string) FlagOption

func Mandatory

func Mandatory() FlagOption

func Persistent

func Persistent() FlagOption

type FlagType

type FlagType func(fi *FlagInfo, fs *pflag.FlagSet)

func Bool added in v0.4.0

func Bool() FlagType

Defines a boolean flag. Boolean flags are false by default.

func Duration added in v0.4.0

func Duration(def time.Duration) FlagType

Defines a duration flag with a default value.

func Float64 added in v0.4.0

func Float64(def float64) FlagType

Defines a decimal flag with a default value.

func Int added in v0.4.0

func Int(def int) FlagType

Defines an integer flag with a default value.

func Str

func Str(def string) FlagType

Defines a string flag with a default value.

Jump to

Keyboard shortcuts

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