ft-sync/config/client/config.go
Simon Vieille 3af050caa0 add gorm
add history init/pull/push
2024-08-28 20:36:03 +02:00

44 lines
797 B
Go

package client
import (
"flag"
"os"
"strings"
)
type Config struct {
Server string
Path string
Hostname string
}
var config *Config
func GetConfig() *Config {
if config == nil {
config = &Config{}
}
return config
}
func (c *Config) Define(server, hostname, path string) {
c.Server = strings.TrimRight(server, "/")
c.Hostname = hostname
c.Path = path
}
func (c *Config) DbPath(name string) string {
return c.Path + "/" + name + ".db"
}
func InitConfig() {
defaultHostname, _ := os.Hostname()
path := flag.String("p", os.Getenv("HOME")+"/.config/FreeTube", "Path to FreeTube config directory")
hostname := flag.String("h", defaultHostname, "Hostname")
server := flag.String("s", "", "Server to sync")
flag.Parse()
GetConfig().Define(*server, *hostname, *path)
}