config

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const EnvPrefix = "CSS_"

Variables

View Source
var ErrInvalidIP = errors.New("failed to parse IP")

Functions

func InitLog

func InitLog(w io.Writer, level slog.Level, format LogFormat)

func LogFormatStrings

func LogFormatStrings() []string

LogFormatStrings returns a slice of all String values of the enum

func NewContext

func NewContext(ctx context.Context, conf *Config) context.Context

func RegisterCompletions

func RegisterCompletions(cmd *cobra.Command)

func RegisterFlags

func RegisterFlags(cmd *cobra.Command)

Types

type Config

type Config struct {
	LogLevel  string `yaml:"log-level"`
	LogFormat string `yaml:"log-format"`

	DeviceAddrStrs        []string            `yaml:"devices"`
	DeviceAddrs           []castdns.CastEntry `yaml:"-"`
	DiscoverInterval      time.Duration       `yaml:"discover-interval"`
	PausedInterval        time.Duration       `yaml:"paused-interval"`
	PlayingInterval       time.Duration       `yaml:"playing-interval"`
	SkipDelay             time.Duration       `yaml:"skip-delay"`
	IgnoreSegmentDuration time.Duration       `yaml:"ignore-segment-duration"`

	NetworkInterfaceName string         `yaml:"network-interface"`
	NetworkInterface     *net.Interface `yaml:"-"`

	SkipSponsors bool     `yaml:"skip-sponsors"`
	Categories   []string `yaml:"categories"`
	ActionTypes  []string `yaml:"action-types"`

	YouTubeAPIKey string `yaml:"youtube-api-key"`
	MuteAds       bool   `yaml:"mute-ads"`
}

func FromContext

func FromContext(ctx context.Context) *Config

func Load

func Load(cmd *cobra.Command) (*Config, error)

func New

func New() *Config

func (*Config) InitLog

func (c *Config) InitLog(w io.Writer)

type LogFormat

type LogFormat uint8
const (
	FormatAuto LogFormat = iota
	FormatColor
	FormatPlain
	FormatJSON
)

func LogFormatString

func LogFormatString(s string) (LogFormat, error)

LogFormatString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func LogFormatValues

func LogFormatValues() []LogFormat

LogFormatValues returns all values of the enum

func (LogFormat) IsALogFormat

func (i LogFormat) IsALogFormat() bool

IsALogFormat returns "true" if the value is listed in the enum definition. "false" otherwise

func (LogFormat) MarshalText

func (i LogFormat) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for LogFormat

func (LogFormat) String

func (i LogFormat) String() string

func (*LogFormat) UnmarshalText

func (i *LogFormat) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for LogFormat

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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