From dfebc9013b5414e9a3c5f940704e831c31ce35d2 Mon Sep 17 00:00:00 2001 From: tjp Date: Sun, 14 Jan 2024 19:54:15 -0700 Subject: fixes --- files.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'files.go') diff --git a/files.go b/files.go index 052c4fb..4964750 100644 --- a/files.go +++ b/files.go @@ -11,17 +11,19 @@ import ( "path/filepath" "strings" "syscall" + "time" "github.com/BurntSushi/toml" ) type ConfigMain struct { - DefaultScheme string `toml:"default_scheme"` - SoftWrap int `toml:"soft_wrap"` - DownloadFolder string `toml:"download_folder"` - VimKeys bool `toml:"vim_keys"` - Quiet bool `toml:"quiet"` - Pager string `toml:"pager"` + DefaultScheme string `toml:"default_scheme"` + SoftWrap int `toml:"soft_wrap"` + DownloadFolder string `toml:"download_folder"` + VimKeys bool `toml:"vim_keys"` + Quiet bool `toml:"quiet"` + Pager string `toml:"pager"` + Timeout duration `toml:"duration"` } type Config struct { @@ -30,6 +32,14 @@ type Config struct { Handlers map[string]string `toml:"handlers"` } +type duration struct{ time.Duration } + +func (d *duration) UnmarshalText(text []byte) error { + var err error + d.Duration, err = time.ParseDuration(string(text)) + return err +} + func getConfig() (*Config, error) { home := os.Getenv("HOME") path := os.Getenv("XDG_CONFIG_HOME") @@ -50,6 +60,9 @@ func getConfig() (*Config, error) { DownloadFolder: home, Quiet: false, Pager: "auto", + Timeout: duration{ + time.Duration(10 * time.Second), + }, }, Handlers: map[string]string{}, } -- cgit v1.2.3