config

package
v0.0.0-...-b0a1b23 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Video VideoSection `toml:"video"`
	Lirc  LircSection  `toml:"lirc"`
}

Config represents the fields in the configuration file.

func (*File) GetConfigDirPath

func (config *File) GetConfigDirPath() (string, error)

GetConfigDirPath retrieves the absolute path to the configuration directory in an OS independent way.

Returns: (absolute path to the configuration direction, any error) If an error occurs, an empty string is returned as the path.

func (*File) GetConfigFilePath

func (config *File) GetConfigFilePath() (string, error)

GetConfigFilePath retrieves the absolute path to the configuration file in an OS independent way.

Lookup hierarchy:

  1. HC_CONFIG_PATH environment variable. This will only be used if the path set in the environment variable is file that exists.
  2. ~/.hc/config.toml will be looked for next. This is the configuration path to the user-defined configuration.
  3. Internal config file in the package will be used. This is the configuration file that is used by default if the above two do not exist.

Returns: (the absolute path to configuration file, any error) If an error occurs, an empty string is returned as the path.

func (*File) Output

func (config *File) Output() error

Output outputs the configuration file to stdout.

func (*File) Parse

func (config *File) Parse() error

Parse parses the config file and reads the fields into this File. After it is parsed, you can then directly access the fields.

Example:

config.Parse()
config.video.device = "/dev/device0"
config.Save()

func (*File) Save

func (config *File) Save() error

Save saves the current state of this file.

func (*File) SetupUserConfig

func (config *File) SetupUserConfig() (bool, bool, error)

SetupUserConfig initializes the user's configuration file setup by creating the configuration folder at ~/.hc/ and configuration file at ~/.hc/config.toml. It only creates these if they do not exist already.

Returns: (if folder is created, if file is created, any error)

type LircSection

type LircSection struct {
	Remote string `toml:"remote"`
}

type VideoSection

type VideoSection struct {
	Device string `toml:"device"`
}

Jump to

Keyboard shortcuts

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