Move config to gmitohtml namespace

This commit is contained in:
Aaron Fischer 2021-07-09 23:19:30 +02:00
parent 0bec3c3eef
commit 2fdec61b41

View file

@ -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)
}