Documentation ¶
Index ¶
- Constants
- func DefaultLogger(clioCfg Config, store redact.Store) (logger.Logger, error)
- func ExitEvent(interrupt bool) partybus.Event
- func VersionCommand(id Identification, additions ...versionAddition) *cobra.Command
- type Application
- type BusConstructor
- type Config
- type DevelopmentConfig
- type FieldDescriber
- type FieldDescriptionSet
- type FlagAdder
- type FlagSet
- type Identification
- type Initializer
- type LoggerConstructor
- type LoggingConfig
- type PostLoader
- type PostRun
- type Profile
- type SetupConfig
- func (c *SetupConfig) WithBusConstructor(constructor BusConstructor) *SetupConfig
- func (c *SetupConfig) WithConfigFinders(finders ...fangs.Finder) *SetupConfig
- func (c *SetupConfig) WithConfigInRootHelp() *SetupConfig
- func (c *SetupConfig) WithDevelopmentConfig(cfg DevelopmentConfig) *SetupConfig
- func (c *SetupConfig) WithGlobalConfigFlag() *SetupConfig
- func (c *SetupConfig) WithGlobalLoggingFlags() *SetupConfig
- func (c *SetupConfig) WithInitializers(initializers ...Initializer) *SetupConfig
- func (c *SetupConfig) WithLoggerConstructor(constructor LoggerConstructor) *SetupConfig
- func (c *SetupConfig) WithLoggingConfig(cfg LoggingConfig) *SetupConfig
- func (c *SetupConfig) WithNoBus() *SetupConfig
- func (c *SetupConfig) WithNoLogging() *SetupConfig
- func (c *SetupConfig) WithPostRuns(postRuns ...PostRun) *SetupConfig
- func (c *SetupConfig) WithUI(uis ...UI) *SetupConfig
- func (c *SetupConfig) WithUIConstructor(constructor UIConstructor) *SetupConfig
- type State
- type UI
- type UIConstructor
Constants ¶
const ExitEventType partybus.EventType = "clio-exit"
Variables ¶
This section is empty.
Functions ¶
func VersionCommand ¶
func VersionCommand(id Identification, additions ...versionAddition) *cobra.Command
Types ¶
type Application ¶
type Application interface { ID() Identification AddFlags(flags *pflag.FlagSet, cfgs ...any) SetupCommand(cmd *cobra.Command, cfgs ...any) *cobra.Command SetupRootCommand(cmd *cobra.Command, cfgs ...any) *cobra.Command Run() }
func New ¶
func New(cfg SetupConfig) Application
type BusConstructor ¶
type BusConstructor func(Config) *partybus.Bus
type Config ¶
type Config struct { // Items that end up in the target application configuration Log *LoggingConfig `yaml:"log" json:"log" mapstructure:"log"` Dev *DevelopmentConfig `yaml:"dev" json:"dev" mapstructure:"dev"` // this is a list of all "config" objects from SetupCommand calls FromCommands []any `yaml:"-" json:"-" mapstructure:"-"` }
type DevelopmentConfig ¶
type DevelopmentConfig struct {
Profile Profile `yaml:"profile" json:"profile" mapstructure:"profile"`
}
func (*DevelopmentConfig) DescribeFields ¶
func (d *DevelopmentConfig) DescribeFields(set fangs.FieldDescriptionSet)
func (*DevelopmentConfig) PostLoad ¶
func (d *DevelopmentConfig) PostLoad() error
type FieldDescriber ¶
type FieldDescriber interface {
DescribeFields(descriptions FieldDescriptionSet)
}
FieldDescriber a struct implementing this interface will have DescribeFields called when the config is summarized
type FieldDescriptionSet ¶
type FieldDescriptionSet = fangs.FieldDescriptionSet
FieldDescriptionSet FieldDescriber.DescribeFields will be called with this interface to add field descriptions
type FlagAdder ¶
type FlagAdder interface {
AddFlags(flags FlagSet)
}
FlagAdder interface can be implemented by structs in order to add flags when AddFlags is called
type FlagSet ¶
FlagSet is a facade of pflag.FlagSet, restricting the types of calls to what fangs needs
type Identification ¶
type Identification struct { Name string `json:"application,omitempty"` // application name Version string `json:"version,omitempty"` // application semantic version GitCommit string `json:"gitCommit,omitempty"` // git SHA at build-time GitDescription string `json:"gitDescription,omitempty"` // indication of git tree (either "clean" or "dirty") at build-time BuildDate string `json:"buildDate,omitempty"` // date of the build }
Identification defines the application name and version details (generally from build information)
type Initializer ¶
type LoggingConfig ¶
type LoggingConfig struct { Quiet bool `yaml:"quiet" json:"quiet" mapstructure:"quiet"` // -q, indicates to not show any status output to stderr Verbosity int `yaml:"-" json:"-" mapstructure:"verbosity"` // -v or -vv , controlling which UI (ETUI vs logging) and what the log level should be Level logger.Level `yaml:"level" json:"level" mapstructure:"level"` // the log level string hint FileLocation string `yaml:"file" json:"file" mapstructure:"file"` // the file path to write logs to // contains filtered or unexported fields }
LoggingConfig contains all logging-related configuration options available to the user via the application config.
func (*LoggingConfig) AddFlags ¶
func (l *LoggingConfig) AddFlags(flags fangs.FlagSet)
func (*LoggingConfig) DescribeFields ¶
func (l *LoggingConfig) DescribeFields(d fangs.FieldDescriptionSet)
func (*LoggingConfig) PostLoad ¶
func (l *LoggingConfig) PostLoad() error
type PostLoader ¶
type PostLoader = fangs.PostLoader
PostLoader is the interface used to do any sort of processing after the entire struct has been populated from the configuration files and environment variables
type SetupConfig ¶
type SetupConfig struct { // Metadata about the target application ID Identification // Default configuration items that end up in the target application configuration DefaultLoggingConfig *LoggingConfig DefaultDevelopmentConfig *DevelopmentConfig // Items required for setting up the application (clio-only configuration) FangsConfig fangs.Config BusConstructor BusConstructor LoggerConstructor LoggerConstructor UIConstructor UIConstructor Initializers []Initializer // contains filtered or unexported fields }
func NewSetupConfig ¶
func NewSetupConfig(id Identification) *SetupConfig
func (*SetupConfig) WithBusConstructor ¶
func (c *SetupConfig) WithBusConstructor(constructor BusConstructor) *SetupConfig
func (*SetupConfig) WithConfigFinders ¶
func (c *SetupConfig) WithConfigFinders(finders ...fangs.Finder) *SetupConfig
func (*SetupConfig) WithConfigInRootHelp ¶
func (c *SetupConfig) WithConfigInRootHelp() *SetupConfig
func (*SetupConfig) WithDevelopmentConfig ¶
func (c *SetupConfig) WithDevelopmentConfig(cfg DevelopmentConfig) *SetupConfig
func (*SetupConfig) WithGlobalConfigFlag ¶
func (c *SetupConfig) WithGlobalConfigFlag() *SetupConfig
WithGlobalConfigFlag adds the global `-c` / `--config` flags to the root command
func (*SetupConfig) WithGlobalLoggingFlags ¶
func (c *SetupConfig) WithGlobalLoggingFlags() *SetupConfig
WithGlobalLoggingFlags adds the global logging flags to the root command.
func (*SetupConfig) WithInitializers ¶
func (c *SetupConfig) WithInitializers(initializers ...Initializer) *SetupConfig
func (*SetupConfig) WithLoggerConstructor ¶
func (c *SetupConfig) WithLoggerConstructor(constructor LoggerConstructor) *SetupConfig
func (*SetupConfig) WithLoggingConfig ¶
func (c *SetupConfig) WithLoggingConfig(cfg LoggingConfig) *SetupConfig
func (*SetupConfig) WithNoBus ¶
func (c *SetupConfig) WithNoBus() *SetupConfig
func (*SetupConfig) WithNoLogging ¶
func (c *SetupConfig) WithNoLogging() *SetupConfig
func (*SetupConfig) WithPostRuns ¶
func (c *SetupConfig) WithPostRuns(postRuns ...PostRun) *SetupConfig
func (*SetupConfig) WithUI ¶
func (c *SetupConfig) WithUI(uis ...UI) *SetupConfig
func (*SetupConfig) WithUIConstructor ¶
func (c *SetupConfig) WithUIConstructor(constructor UIConstructor) *SetupConfig