Documentation ¶
Overview ¶
Package king is a library to configure the command line parser https://github.com/alecthomas/kong
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOptions ¶
DefaultOptions creates a set of opinionated options.
func EnvResolver ¶
EnvResolver returns a Resolver that retrieves values from environment variables.
Hyphens in flag names are replaced with underscores. Flag names are prefixed with app name and converted to uppercase.
Usage: ctx := kong.Parse(&cli, kong.Resolvers(pfkong.EnvResolver()), ) }
Types ¶
type BuildInfo ¶
type BuildInfo struct {
// contains filtered or unexported fields
}
BuildInfo represents build information.
func NewBuildInfo ¶
NewBuildInfo creates BuildInformation from version, revision and date. These values are typically set with ldflags (via goreleaser for example).
The date has to be in time.RFC3339 format and the revision must be at least 8 chars long.
type Config ¶
type Config struct { Context context.Context Name string Description string BuildInfo *BuildInfo ConfigPaths []string }
Config is used to create DefaultOptions.
type Map ¶
type Map map[string]interface{}
Map is a map with string as key and interface{} as value.
func FlagMap ¶
FlagMap returns the flags and corresponding values from *kong.Context.
To prevent logging sensitive flag values it is possible to provide a list of regular expressions. Flag values of flag names that match are redacted by '*'.
func (Map) List ¶
func (m Map) List() []interface{}
List returns the flag and values as list (sorted by keys).
func (Map) Register ¶
func (m Map) Register(program string, registerer prometheus.Registerer) Map
Register registers prometheus flag collectors that display configured flags as metrics. The genereated metrics are of the form:
kong_flag{program="progname", name="flagname", value="flagvalue"} 1
type Option ¶
Option is a BuildInfo functional option.
func WithDateString ¶
WithDateString sets the build date (RFC3339).
func WithLocation ¶
WithLocation sets the timezone for the build date.
type ShowConfig ¶
type ShowConfig bool
ShowConfig can be used to show information about the parsed configuration files.
func (ShowConfig) BeforeApply ¶
BeforeApply is the actual show-config command.
type VersionFlag ¶
type VersionFlag bool
VersionFlag displays the version information stored in "version" key form kong.Vars.
Use this flag to show version information.
func (VersionFlag) BeforeApply ¶
BeforeApply is the actual version command.