Documentation
¶
Index ¶
- func GetDefaultConfig() []byte
- func GetPlatformDefaultConfig() []byte
- func LoadAndMergeFile(v *viper.Viper, filename string) (string, error)
- func LoadConfig(filename string, withDefaults bool) (*viper.Viper, string, error)
- func LoadDefaults(v *viper.Viper, defaults []byte) error
- type AppConfig
- func (c *AppConfig) GetAppState() *AppState
- func (c *AppConfig) GetBuildDate() string
- func (c *AppConfig) GetBuildSource() string
- func (c *AppConfig) GetCommit() string
- func (c *AppConfig) GetDebug() bool
- func (c *AppConfig) GetName() string
- func (c *AppConfig) GetUserConfig() *viper.Viper
- func (c *AppConfig) GetUserConfigDir() string
- func (c *AppConfig) GetVersion() string
- func (c *AppConfig) LoadAppState() error
- func (c *AppConfig) SaveAppState() error
- func (c *AppConfig) WriteToUserConfig(key string, value interface{}) error
- type AppConfigurer
- type AppState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultConfig ¶
func GetDefaultConfig() []byte
GetDefaultConfig returns the application default configuration
func GetPlatformDefaultConfig ¶
func GetPlatformDefaultConfig() []byte
GetPlatformDefaultConfig gets the defaults for the platform
func LoadAndMergeFile ¶
LoadAndMergeFile Loads the config/state file, creating the file has an empty one if it does not exist
func LoadConfig ¶
LoadConfig gets the user's config
Types ¶
type AppConfig ¶
type AppConfig struct {
Debug bool `long:"debug" env:"DEBUG" default:"false"`
Version string `long:"version" env:"VERSION" default:"unversioned"`
Commit string `long:"commit" env:"COMMIT"`
BuildDate string `long:"build-date" env:"BUILD_DATE"`
Name string `long:"name" env:"NAME" default:"lazynpm"`
BuildSource string `long:"build-source" env:"BUILD_SOURCE" default:""`
UserConfig *viper.Viper
UserConfigDir string
AppState *AppState
}
AppConfig contains the base configuration fields required for lazynpm.
func NewAppConfig ¶
func NewAppConfig(name, version, commit, date string, buildSource string, debuggingFlag bool) (*AppConfig, error)
NewAppConfig makes a new app config
func (*AppConfig) GetAppState ¶
GetAppState returns the app state
func (*AppConfig) GetBuildDate ¶
GetBuildDate returns debug flag
func (*AppConfig) GetBuildSource ¶
GetBuildSource returns the source of the build. For builds from goreleaser this will be binaryBuild
func (*AppConfig) GetUserConfig ¶
GetUserConfig returns the user config
func (*AppConfig) GetUserConfigDir ¶
func (*AppConfig) GetVersion ¶
GetVersion returns debug flag
func (*AppConfig) LoadAppState ¶
LoadAppState loads recorded AppState from file
func (*AppConfig) SaveAppState ¶
SaveAppState marshalls the AppState struct and writes it to the disk
func (*AppConfig) WriteToUserConfig ¶
WriteToUserConfig adds a key/value pair to the user's config and saves it
type AppConfigurer ¶
type AppConfigurer interface {
GetDebug() bool
GetVersion() string
GetCommit() string
GetBuildDate() string
GetName() string
GetBuildSource() string
GetUserConfig() *viper.Viper
GetUserConfigDir() string
GetAppState() *AppState
WriteToUserConfig(string, interface{}) error
SaveAppState() error
LoadAppState() error
}
AppConfigurer interface allows individual app config structs to inherit Fields from AppConfig and still be used by lazynpm.