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.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rhctl/conf.go b/src/rhctl/conf.go
index acd5cd1..7a1aea0 100644
--- a/src/rhctl/conf.go
+++ b/src/rhctl/conf.go
@@ -23,6 +23,8 @@ package main
import (
"os"
+ "strings"
+ "time"
"github.com/naoina/toml"
)
@@ -31,6 +33,7 @@ type Config struct {
Audioswitch struct {
Device string `toml:"dev"`
Baudrate Baudrate `toml:"baud"`
+ Timeout Duration `toml:"timeout"`
}
Servers map[string]struct {
@@ -47,6 +50,16 @@ type Config struct {
}
}
+type Duration struct {
+ time.Duration
+}
+
+func (d *Duration) UnmarshalTOML(data []byte) (err error) {
+ ds := strings.TrimRight(strings.TrimLeft(string(data), "\""), "\"")
+ d.Duration, err = time.ParseDuration(ds)
+ return
+}
+
func ReadConfig(configfile string) (conf *Config, err error) {
conf = &Config{}
@@ -60,5 +73,10 @@ func ReadConfig(configfile string) (conf *Config, err error) {
if err = decoder.Decode(conf); err != nil {
return
}
+
+ if conf.Audioswitch.Timeout.Duration <= time.Duration(0) {
+ conf.Audioswitch.Timeout.Duration = time.Second
+ }
+
return
}