blob: 447fc150220577b762323ad25fc54c505a057638 (
plain) (
blame)
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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"fmt"
"os"
"path/filepath"
"krino/internal/config"
"krino/internal/xdg"
)
// cacheDir is where every directory's keyword cache lives (spec §6.1), the
// same place krino uses.
func cacheDir() string {
return filepath.Join(xdg.CacheHome(), "krino")
}
// mainFile is -c FILE, or the default krino.conf - the same rule the
// command line follows, tilde and all.
func mainFile(conf string) string {
if conf != "" {
return xdg.Expand(conf)
}
return config.DefaultFile()
}
// printDiags reports configuration problems the way krino(1) does, so a
// file that will not load reads the same however it was opened.
func printDiags(errs []*config.Diag) {
for _, e := range errs {
d := *e
d.File = xdg.Abbrev(d.File)
fmt.Fprintln(os.Stderr, &d)
}
if len(errs) == 1 {
fmt.Fprintln(os.Stderr, "krino-gui: 1 problem found")
} else {
fmt.Fprintf(os.Stderr, "krino-gui: %d problems found\n", len(errs))
}
}
|