From 2fdec61b41e41f6387f10cc089e33745bc111945 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Fri, 9 Jul 2021 23:19:30 +0200 Subject: [PATCH] Move config to gmitohtml namespace --- config.go => pkg/gmitohtml/config.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) rename config.go => pkg/gmitohtml/config.go (78%) diff --git a/config.go b/pkg/gmitohtml/config.go similarity index 78% rename from config.go rename to pkg/gmitohtml/config.go index 5d26292..b4dace8 100644 --- a/config.go +++ b/pkg/gmitohtml/config.go @@ -1,4 +1,4 @@ -package main +package gmitohtml import ( "crypto/tls" @@ -8,7 +8,6 @@ import ( "os" "path" - "code.rocketnine.space/tslocum/gmitohtml/pkg/gmitohtml" "gopkg.in/yaml.v3" ) @@ -28,7 +27,7 @@ type appConfig struct { Certs map[string]*certConfig } -var config = &appConfig{ +var Config = &appConfig{ Bookmarks: make(map[string]string), ConvertImages: false, @@ -36,7 +35,7 @@ var config = &appConfig{ Certs: make(map[string]*certConfig), } -func defaultConfigPath() string { +func DefaultConfigPath() string { homedir, err := os.UserHomeDir() if err == nil && homedir != "" { return path.Join(homedir, ".config", "gmitohtml", "config.yaml") @@ -44,7 +43,7 @@ func defaultConfigPath() string { return "" } -func readconfig(configPath string) error { +func ReadConfig(configPath string) error { if configPath == "" { return errors.New("file unspecified") } @@ -59,15 +58,15 @@ func readconfig(configPath string) error { if err != nil { return err } - config = newConfig + Config = newConfig return nil } -func saveConfig(configPath string) error { - config.Bookmarks = gmitohtml.GetBookmarks() +func SaveConfig(configPath string) error { + Config.Bookmarks = GetBookmarks() - out, err := yaml.Marshal(config) + out, err := yaml.Marshal(Config) if err != nil { return fmt.Errorf("failed to marshal configuration: %s", err) }