-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.go
41 lines (35 loc) · 941 Bytes
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
)
var configFile *string = flag.String("config-file", "", "Location of the config file")
func importConfig() *Config {
if len(*configFile) == 0 {
homeDir := os.Getenv("HOME")
if len(homeDir) == 0 {
// alert(term, "$HOME not set. Please either export $HOME or use the -config-file option.\n")
// TODO throw error
}
persistentDir := filepath.Join(homeDir, "Persistent")
if stat, err := os.Lstat(persistentDir); err == nil && stat.IsDir() {
// Looks like Tails.
homeDir = persistentDir
}
*configFile = filepath.Join(homeDir, ".xmpp-gui")
}
fmt.Printf("Parsing the config file...\n")
config, err := ParseConfig(*configFile)
if err != nil {
fmt.Printf("Failed to parse config file: %s\n", err.Error())
//config = new(Config)
// if !enroll(config, term) {
// return
//}
config.filename = *configFile
config.Save()
}
return config
}