Commit
+38 -40 +/-4 browse
1 | diff --git a/go.mod b/go.mod |
2 | index 6fcb700..540b414 100644 |
3 | --- a/go.mod |
4 | +++ b/go.mod |
5 | @@ -4,16 +4,13 @@ go 1.15 |
6 | |
7 | require ( |
8 | github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 |
9 | + github.com/adrg/xdg v0.4.0 |
10 | github.com/fatih/color v1.12.0 |
11 | - github.com/gizak/termui v2.3.0+incompatible |
12 | github.com/gizak/termui/v3 v3.1.0 |
13 | github.com/jawher/mow.cli v1.2.0 |
14 | - github.com/maruel/panicparse v0.0.0-20180806203336-f20d4c4d746f |
15 | - github.com/mattn/go-colorable v0.1.8 |
16 | - github.com/mattn/go-isatty v0.0.13 |
17 | - github.com/mattn/go-runewidth v0.0.13 |
18 | + github.com/mattn/go-isatty v0.0.13 // indirect |
19 | + github.com/mattn/go-runewidth v0.0.13 // indirect |
20 | github.com/mattn/go-sqlite3 v1.14.8 |
21 | - github.com/mitchellh/go-wordwrap v1.0.1 |
22 | - github.com/nsf/termbox-go v1.1.1 |
23 | - golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c |
24 | + github.com/mitchellh/go-wordwrap v1.0.1 // indirect |
25 | + github.com/nsf/termbox-go v1.1.1 // indirect |
26 | ) |
27 | diff --git a/go.sum b/go.sum |
28 | index 7d3c61e..7acffdd 100644 |
29 | --- a/go.sum |
30 | +++ b/go.sum |
31 | @@ -1,52 +1,34 @@ |
32 | - github.com/0xAX/notificator v0.0.0-20181105090803-d81462e38c21 h1:moSC7ACaTejHmVRRwfDTMgByRSwjg2vZooncdWLj7o8= |
33 | - github.com/0xAX/notificator v0.0.0-20181105090803-d81462e38c21/go.mod h1:NtXa9WwQsukMHZpjNakTTz0LArxvGYdPA9CjIcUSZ6s= |
34 | github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 h1:j9HaafapDbPbGRDku6e/HRs6KBMcKHiWcm1/9Sbxnl4= |
35 | github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1/go.mod h1:NtXa9WwQsukMHZpjNakTTz0LArxvGYdPA9CjIcUSZ6s= |
36 | + github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= |
37 | + github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= |
38 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
39 | + github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
40 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
41 | - github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= |
42 | - github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= |
43 | github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= |
44 | github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= |
45 | - github.com/gizak/termui v2.3.0+incompatible h1:S8wJoNumYfc/rR5UezUM4HsPEo3RJh0LKdiuDWQpjqw= |
46 | - github.com/gizak/termui v2.3.0+incompatible/go.mod h1:PkJoWUt/zacQKysNfQtcw1RW+eK2SxkieVBtl+4ovLA= |
47 | github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= |
48 | github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= |
49 | - github.com/jawher/mow.cli v1.0.4 h1:hKjm95J7foZ2ngT8tGb15Aq9rj751R7IUDjG+5e3cGA= |
50 | - github.com/jawher/mow.cli v1.0.4/go.mod h1:5hQj2V8g+qYmLUVWqu4Wuja1pI57M83EChYLVZ0sMKk= |
51 | github.com/jawher/mow.cli v1.2.0 h1:e6ViPPy+82A/NFF/cfbq3Lr6q4JHKT9tyHwTCcUQgQw= |
52 | github.com/jawher/mow.cli v1.2.0/go.mod h1:y+pcA3jBAdo/GIZx/0rFjw/K2bVEODP9rfZOfaiq8Ko= |
53 | - github.com/maruel/panicparse v0.0.0-20180806203336-f20d4c4d746f h1:qiwX3rjQBtp68F8LsKgURRQiFCWiNdN8EB9b+EMLv1k= |
54 | - github.com/maruel/panicparse v0.0.0-20180806203336-f20d4c4d746f/go.mod h1:nty42YY5QByNC5MM7q/nj938VbgPU7avs45z6NClpxI= |
55 | - github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= |
56 | - github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= |
57 | github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= |
58 | github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= |
59 | - github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= |
60 | - github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= |
61 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= |
62 | github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= |
63 | github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= |
64 | github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= |
65 | - github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= |
66 | - github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= |
67 | github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= |
68 | github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= |
69 | github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= |
70 | - github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= |
71 | - github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= |
72 | github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU= |
73 | github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= |
74 | github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= |
75 | - github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= |
76 | - github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= |
77 | github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= |
78 | github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= |
79 | - github.com/nsf/termbox-go v0.0.0-20190104133558-0938b5187e61 h1:pEzZYac/uQ4cgaN1Q/UYZg+ZtCSWz2HQ3rvl8MeN9MA= |
80 | - github.com/nsf/termbox-go v0.0.0-20190104133558-0938b5187e61/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= |
81 | github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= |
82 | github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY= |
83 | github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo= |
84 | + github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
85 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
86 | github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= |
87 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
88 | @@ -54,11 +36,15 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ |
89 | github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= |
90 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
91 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= |
92 | - golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
93 | + github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= |
94 | + github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
95 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
96 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
97 | - golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= |
98 | - golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
99 | + golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik= |
100 | + golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
101 | + gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= |
102 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
103 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
104 | gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
105 | + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= |
106 | + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
107 | diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go |
108 | index 9aaa5ae..b249a9a 100644 |
109 | --- a/pkg/cmd/cmd.go |
110 | +++ b/pkg/cmd/cmd.go |
111 | @@ -5,13 +5,13 @@ import ( |
112 | "encoding/json" |
113 | "fmt" |
114 | "os" |
115 | - "os/user" |
116 | "path" |
117 | "sort" |
118 | "strconv" |
119 | "strings" |
120 | "time" |
121 | |
122 | + "github.com/adrg/xdg" |
123 | cli "github.com/jawher/mow.cli" |
124 | |
125 | pomo "github.com/kevinschoon/pomo/pkg/internal" |
126 | @@ -25,9 +25,7 @@ func maybe(err error) { |
127 | } |
128 | |
129 | func defaultConfigPath() string { |
130 | - u, err := user.Current() |
131 | - maybe(err) |
132 | - return path.Join(u.HomeDir, "/.pomo/config.json") |
133 | + return path.Join(xdg.ConfigHome, "pomo", "config.json") |
134 | } |
135 | |
136 | func parseRange(arg string) (int, int, error) { |
137 | diff --git a/pkg/internal/config.go b/pkg/internal/config.go |
138 | index 0df5cfb..d4ecf3c 100644 |
139 | --- a/pkg/internal/config.go |
140 | +++ b/pkg/internal/config.go |
141 | @@ -7,6 +7,7 @@ import ( |
142 | "os" |
143 | "path" |
144 | |
145 | + "github.com/adrg/xdg" |
146 | "github.com/fatih/color" |
147 | ) |
148 | |
149 | @@ -109,15 +110,31 @@ func LoadConfig(configPath string, config *Config) error { |
150 | } |
151 | if config.BasePath == "" { |
152 | config.BasePath = path.Dir(configPath) |
153 | + err := os.MkdirAll(config.BasePath, os.ModePerm) |
154 | + if err != nil { |
155 | + return err |
156 | + } |
157 | } |
158 | if config.DBPath == "" { |
159 | - config.DBPath = path.Join(config.BasePath, "/pomo.db") |
160 | + config.DBPath = path.Join(xdg.DataHome, "pomo", "pomo.db") |
161 | + err := os.MkdirAll(path.Dir(config.DBPath), os.ModePerm) |
162 | + if err != nil { |
163 | + return err |
164 | + } |
165 | } |
166 | if config.SocketPath == "" { |
167 | - config.SocketPath = path.Join(config.BasePath, "/pomo.sock") |
168 | + config.SocketPath = path.Join(xdg.RuntimeDir, "pomo.sock") |
169 | + err := os.MkdirAll(path.Dir(config.SocketPath), os.ModePerm) |
170 | + if err != nil { |
171 | + return err |
172 | + } |
173 | } |
174 | if config.IconPath == "" { |
175 | - config.IconPath = path.Join(config.BasePath, "/icon.png") |
176 | + config.IconPath = path.Join(xdg.DataHome, "pomo", "icon.png") |
177 | + err := os.MkdirAll(path.Dir(config.IconPath), os.ModePerm) |
178 | + if err != nil { |
179 | + return err |
180 | + } |
181 | } |
182 | if config.Publish && (config.PublishSocketPath == "" || config.PublishSocketPath == config.SocketPath) { |
183 | return fmt.Errorf("'publish' option now requires 'publishSocketPath' which must not be the same as 'socketPath'") |