application

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrEnvConfigurationAlreadyLoadedMessage = " environment is already loaded"
	ErrEnvConfigurationIsEmptyMessage       = "environment configuration does not define keys"
	ErrEnvConfigurationNotLoadedMessage     = "environment not loaded"
	ErrFileConfigurationExistsMessage       = "configuration exists"
	ErrFileConfigurationNotFoundMessage     = "configuration not found"
)

Variables

View Source
var (
	ErrEnvConfigurationAlreadyLoaded = EnvConfigurationAlreadyLoadedError{/* contains filtered or unexported fields */}
	ErrEnvConfigurationIsEmpty       = EnvConfigurationIsEmptyError{/* contains filtered or unexported fields */}
	ErrEnvConfigurationNotLoaded     = EnvConfigurationNotLoadedError{/* contains filtered or unexported fields */}
	ErrFileConfigurationExists       = FileConfigurationExistsError{/* contains filtered or unexported fields */}
	ErrFileConfigurationNotFound     = FileConfigurationNotFoundError{/* contains filtered or unexported fields */}
)

Functions

func AddConfigFileFlag

func AddConfigFileFlag(cmd *cobra.Command, f *ConfigFileFlags, p ConfigFileParams)

func AddConfigFilePathsFlag

func AddConfigFilePathsFlag(cmd *cobra.Command, f *ConfigFileFlags, p ConfigFileParams)

func AddLogFormatFlag

func AddLogFormatFlag(cmd *cobra.Command, f *LogFlags, p LogParams)

func AddLogLevelFlag

func AddLogLevelFlag(cmd *cobra.Command, f *LogFlags, p LogParams)

func AddTuiInteractiveFlag

func AddTuiInteractiveFlag(cmd *cobra.Command, f *TuiFlags, p TuiParams)

func ParseLogLevel

func ParseLogLevel(level string) (slog.Level, bool)

func RegisterConfiguration

func RegisterConfiguration(name string, filename string, searchPaths []string) error

func RegisterEnvironment

func RegisterEnvironment(name string, prefix string, keys []string) error

Types

type Application

type Application struct {
	Root    *cobra.Command
	Version Version
}

func NewApplication

func NewApplication(c *cobra.Command, v Version) *Application

func (*Application) RegisterCommands

func (a *Application) RegisterCommands(c []Commander, f func(cmd *cobra.Command))

func (*Application) Run

func (a *Application) Run() error

type BoolSliceVar

type BoolSliceVar struct {
	Name      string
	Shorthand string
	Value     []bool
	Usage     string
}

type BoolVar

type BoolVar struct {
	Name      string
	Shorthand string
	Value     bool
	Usage     string
}

type Command

type Command struct {
	Root        *cobra.Command
	SubCommands []Commander
	Configure   func(cmd *cobra.Command)
}

func (Command) Initialize

func (c Command) Initialize(f func(cmd *cobra.Command)) *cobra.Command

type Commander

type Commander interface {
	Initialize(f func(command *cobra.Command)) *cobra.Command
}

type ConfigFileFlags

type ConfigFileFlags struct {
	Name  string
	Paths []string
}

type ConfigFileParams

type ConfigFileParams struct {
	File  StringVar
	Paths StringSliceVar
}

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}
var Config *Configuration

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) EnvExists

func (c *Configuration) EnvExists(name string) bool

func (*Configuration) FileExists

func (c *Configuration) FileExists(name string) bool

func (*Configuration) GetEnv

func (c *Configuration) GetEnv(name string) (*viper.Viper, error)

func (*Configuration) GetFile

func (c *Configuration) GetFile(name string) (*viper.Viper, error)

func (*Configuration) SetEnvironment

func (c *Configuration) SetEnvironment(name string, v *viper.Viper) error

func (*Configuration) SetFile

func (c *Configuration) SetFile(name string, v *viper.Viper) error

type EnvConfiguration

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

func NewEnvConfiguration

func NewEnvConfiguration(prefix string, keys []string) (EnvConfiguration, error)

func (EnvConfiguration) GetViper

func (e EnvConfiguration) GetViper() (*viper.Viper, error)

func (EnvConfiguration) HasKeys

func (e EnvConfiguration) HasKeys() bool

func (EnvConfiguration) Keys

func (e EnvConfiguration) Keys() []string

func (EnvConfiguration) Prefix

func (e EnvConfiguration) Prefix() string

type EnvConfigurationAlreadyLoadedError

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

func (EnvConfigurationAlreadyLoadedError) Error

type EnvConfigurationIsEmptyError

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

func (EnvConfigurationIsEmptyError) Error

type EnvConfigurationNotLoadedError

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

func (EnvConfigurationNotLoadedError) Error

type FileConfiguration

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

func NewFileConfiguration

func NewFileConfiguration(file string, searchPaths []string) FileConfiguration

func (FileConfiguration) GetViper

func (c FileConfiguration) GetViper() (*viper.Viper, error)

type FileConfigurationExistsError

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

func (FileConfigurationExistsError) Error

type FileConfigurationNotFoundError

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

func (FileConfigurationNotFoundError) Error

type LogFlags

type LogFlags struct {
	Level  string
	Format string
}

type LogFormat

type LogFormat int
const (
	TextLogFormat LogFormat = iota
	JsonLogFormat
)

func ParseLogFormat

func ParseLogFormat(format string) (LogFormat, bool)

func (LogFormat) String

func (f LogFormat) String() string

type LogParams

type LogParams struct {
	Level  StringVar
	Format StringVar
	Output string
}

type StringSliceVar

type StringSliceVar struct {
	Name      string
	Shorthand string
	Value     []string
	Usage     string
}

type StringVar

type StringVar struct {
	Name      string
	Shorthand string
	Value     string
	Usage     string
}

type TuiFlags

type TuiFlags struct {
	Interactive bool
}

type TuiParams

type TuiParams struct {
	Interactive BoolVar
}

type Version

type Version struct {
	SemVer  string
	Commit  string
	Date    string
	Channel string
	RunE    func(v *Version) error
}

func (*Version) Command

func (v *Version) Command() *cobra.Command

func (*Version) String

func (v *Version) String() string

Jump to

Keyboard shortcuts

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