From d2c51030a017133dd51d208dbe6954b070fb9cb9 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 19 Apr 2016 02:43:04 +0200 Subject: rename switch ports to switch inputs @ config diff --git a/sample-config.toml b/sample-config.toml index 33403a4..8d2e2df 100644 --- a/sample-config.toml +++ b/sample-config.toml @@ -3,10 +3,10 @@ dev = "/dev/ttyUSB0" baud = 19200 timeout = "500ms" unit = 0 -ports = [ { number = 1, server = "master", channel = "main" }, - { number = 2, server = "master", channel = "music" }, - { number = 3, server = "standby", channel = "main" }, - { number = 4, server = "standby", channel = "music" } ] +inputs = [ { number = 1, server = "master", channel = "main" }, + { number = 2, server = "master", channel = "music" }, + { number = 3, server = "standby", channel = "main" }, + { number = 4, server = "standby", channel = "music" } ] [servers] diff --git a/src/rhctl/conf.go b/src/rhctl/conf.go index bbf546c..36a3b5a 100644 --- a/src/rhctl/conf.go +++ b/src/rhctl/conf.go @@ -31,23 +31,23 @@ import ( "github.com/naoina/toml" ) -type ConfigSwitchPorts []struct { +type ConfigSwitchInputs []struct { Number SwitchInputNum `toml:"number"` Server string `toml:"server"` Channel string `toml:"channel"` } -func (p ConfigSwitchPorts) Len() int { return len(p) } -func (p ConfigSwitchPorts) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p ConfigSwitchPorts) Less(i, j int) bool { return p[i].Number < p[j].Number } +func (p ConfigSwitchInputs) Len() int { return len(p) } +func (p ConfigSwitchInputs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p ConfigSwitchInputs) Less(i, j int) bool { return p[i].Number < p[j].Number } type Config struct { Audioswitch struct { - Device string `toml:"dev"` - Baudrate Baudrate `toml:"baud"` - Timeout Duration `toml:"timeout"` - Unit SwitchUnitID `toml:"unit"` - Ports ConfigSwitchPorts `toml:"ports"` + Device string `toml:"dev"` + Baudrate Baudrate `toml:"baud"` + Timeout Duration `toml:"timeout"` + Unit SwitchUnitID `toml:"unit"` + Inputs ConfigSwitchInputs `toml:"inputs"` } Servers map[string]struct { @@ -93,9 +93,9 @@ func ReadConfig(configfile string) (conf *Config, err error) { return } - sort.Sort(conf.Audioswitch.Ports) - for i := 1; i < len(conf.Audioswitch.Ports); i++ { - if conf.Audioswitch.Ports[i].Number == conf.Audioswitch.Ports[i-1].Number { + sort.Sort(conf.Audioswitch.Inputs) + for i := 1; i < len(conf.Audioswitch.Inputs); i++ { + if conf.Audioswitch.Inputs[i].Number == conf.Audioswitch.Inputs[i-1].Number { return nil, errors.New("audioswitch port assignments must be unique") } } -- cgit v0.10.2