master
eater 5 years ago
parent 080c1a3d06
commit bc35aece9b
Signed by: eater
GPG Key ID: 656785D50BE51C0A

@ -27,11 +27,17 @@ func LoadConfig(path string) (*Config, error) {
}
func CreateConfig(path string, cfg *Config) {
err := os.MkdirAll(filepath.Dir(path), 0755)
Check(err, "Failed to make directories for %q, err: %s", path, err)
conf, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
Check(err, "Couldn't open %q, err: %s", path, err)
encoder := toml.NewEncoder(conf)
log.Printf("ZeroooConfig: %#v", cfg)
err = encoder.Encode(cfg)
if cfg.Zerooo.Location == "" {
cfg.Zerooo.Location = "/etc/zerooo"
}
if cfg.Zerooo.Location[0] != '/' {
cfg.Zerooo.Location = filepath.Join(filepath.Dir(path), cfg.Zerooo.Location)
}

@ -1,3 +1,3 @@
[zerooo]
location = "/etc/zerooo"
endpoint = "https://zer.ooo"
location = "/etc/zerooo"
endpoint = "https://zer.ooo"

@ -26,7 +26,7 @@ var initCmd = &cobra.Command{
}
if (cmd.Flag("location").Changed) {
if location[0] != '/' {
if len(location) > 0 && location[0] != '/' {
cwd, err := os.Getwd()
service.Check(err, "Can't get current working directory, err: %s", err)
location = filepath.Join(cwd, location)

Loading…
Cancel
Save