Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config #36

Merged
merged 4 commits into from
Oct 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions audiobait.yaml

This file was deleted.

24 changes: 7 additions & 17 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
package main

import (
"io/ioutil"

yaml "gopkg.in/yaml.v1"
goconfig "github.com/TheCacophonyProject/go-config"
)

// AudioConfig contains audio configuration data.
type AudioConfig struct {
AudioDir string `yaml:"audio-directory"`
Card int `yaml:"card"`
VolumeControl string `yaml:"volume-control"`
}

// ParseConfigFile parses the audio config yaml file.
func ParseConfigFile(filename string) (*AudioConfig, error) {
buf, err := ioutil.ReadFile(filename)
func ParseConfig(configDir string) (*goconfig.Audio, error) {
configRW, err := goconfig.New(configDir)
if err != nil {
return nil, err
}

var audioConfig AudioConfig
err = yaml.Unmarshal(buf, &audioConfig)
if err != nil {
audio := goconfig.DefaultAudio()
if err := configRW.Unmarshal(goconfig.AudioKey, &audio); err != nil {
return nil, err
}
return &audioConfig, nil

return &audio, nil
}
12 changes: 3 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ module github.com/TheCacophonyProject/audiobait
go 1.12

require (
github.com/TheCacophonyProject/go-api v0.0.0-20190913044515-638d1f88861e
github.com/TheCacophonyProject/go-api v0.0.0-20190923033957-174cea2ac81c
github.com/TheCacophonyProject/go-config v0.0.0-20190927054511-c93578ae648a
github.com/TheCacophonyProject/modemd v0.0.0-20190708011609-1940f5b6677b
github.com/TheCacophonyProject/window v0.0.0-20190821235241-ab92c2ee24b6
github.com/alexflint/go-arg v1.0.0
github.com/alexflint/go-arg v1.1.0
github.com/godbus/dbus v4.1.0+incompatible
github.com/nathan-osman/go-sunrise v0.0.0-20171121204956-7c449e7c690b // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 // indirect
golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8 // indirect
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0
)
Loading