blob: f26e560206dc10906827ebe9daa73c11b215e6d3 (
plain)
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
42
43
44
45
46
|
package main
import (
"io/ioutil"
"os"
"path/filepath"
"github.com/goulash/xdg"
)
const emptyConfig = `[auth]
username = ""
password_cmd = ""
[profile]
person_id = # ADD PERSON ID
[projects.example]
client = # ADD CLIENT ID
project = # ADD PROJECT ID
module = # ADD MODULE ID
task = 0
work_type = # ADD WORK TYPE ID
billable = true
`
func MaybeWriteConfig() error {
path := xdg.FindConfig("timetasker/config.toml")
if path == "" {
path = filepath.Join(xdg.ConfigHome, "timetasker")
if _, err := os.Stat(path); os.IsNotExist(err) {
os.Mkdir(path, 0700)
}
config_path := filepath.Join(path, "config.toml")
err := ioutil.WriteFile(config_path, []byte(emptyConfig), 0644)
if err != nil {
return err
}
}
return nil
}
|