config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: Apache-2.0 Imports: 26 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 added in v0.8.0

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

func LogFormatStrings added in v0.8.0

func LogFormatStrings() []string

LogFormatStrings returns a slice of all String values of the enum

func NewContext added in v0.8.0

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

func RegisterCompletions added in v0.8.0

func RegisterCompletions(cmd *cobra.Command)

func RegisterFlags added in v0.8.0

func RegisterFlags(cmd *cobra.Command)

Types

type Config added in v0.2.0

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 added in v0.8.0

func FromContext(ctx context.Context) *Config

func Load

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

func New added in v0.8.0

func New() *Config

func (*Config) InitLog added in v0.8.0

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

type LogFormat added in v0.8.0

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

func LogFormatString added in v0.8.0

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 added in v0.8.0

func LogFormatValues() []LogFormat

LogFormatValues returns all values of the enum

func (LogFormat) IsALogFormat added in v0.8.0

func (i LogFormat) IsALogFormat() bool

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

func (LogFormat) MarshalText added in v0.8.0

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

MarshalText implements the encoding.TextMarshaler interface for LogFormat

func (LogFormat) String added in v0.8.0

func (i LogFormat) String() string

func (*LogFormat) UnmarshalText added in v0.8.0

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