config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package config handles the configuration file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToFile

func ToFile(filename string, inst Instance) error

ToFile writes given instance to the specified file.

Types

type Instance

type Instance struct {
	// TimeSpansActive is set to true if time-span related actions are to be performed.
	// If false, it is treated as if all TimeSpan entries were disabled.
	TimeSpansActive bool `json:"time-spans-active"`

	// TimeSpans contains the list of all configured time span entries.
	TimeSpans []TimeSpan `json:"time-spans"`
}

Instance is the main configuration for the whole alarma application.

func Example

func Example() Instance

Example returns a simple filled-out configuration instance.

func FromBytes

func FromBytes(data []byte) (inst Instance, err error)

FromBytes decodes a configuration instance from given byte stream.

func FromFile

func FromFile(filename string) (Instance, error)

FromFile reads given file and returns the corresponding configuration instance, if successful.

func (Instance) ToBytes

func (inst Instance) ToBytes() ([]byte, error)

ToBytes encodes the configuration instance to a byte stream.

type TimeSpan

type TimeSpan struct {
	// ID uniquely identifies the time span.
	ID string `json:"id"`
	// Enabled is set to true to indicate this time span should be active.
	Enabled bool `json:"enabled"`

	// From describes the starting time of the time span. Format: "HH:MM".
	From string `json:"from"`
	// To describes the stopping time of the time span. Format: "HH:MM".
	To string `json:"to"`

	// Path points to the base directory within which audio files are to be searched.
	Path string `json:"path"`
}

TimeSpan describes one action.

Jump to

Keyboard shortcuts

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