summaryrefslogtreecommitdiff
path: root/src/rhctl/conf.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhctl/conf.go')
-rw-r--r--src/rhctl/conf.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/rhctl/conf.go b/src/rhctl/conf.go
index bf68fec..3cfaeac 100644
--- a/src/rhctl/conf.go
+++ b/src/rhctl/conf.go
@@ -40,13 +40,21 @@ type ConfigSwitchInputs []struct {
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 }
-func (p ConfigSwitchInputs) Get(server, channel string) SwitchInputNum {
+func (p ConfigSwitchInputs) GetNumber(server, channel string) (SwitchInputNum, error) {
for _, i := range p {
if i.Server == server && i.Channel == channel {
- return i.Number
+ return i.Number, nil
}
}
- return SwitchInputNum(0)
+ return SwitchInputNum(0), errors.New("no such server/channel")
+}
+func (p ConfigSwitchInputs) GetServerAndChannel(in SwitchInputNum) (string, string, error) {
+ for _, i := range p {
+ if i.Number == in {
+ return i.Server, i.Channel, nil
+ }
+ }
+ return "", "", errors.New("no such input")
}
type Config struct {