diff options
Diffstat (limited to 'gui/cmd/krino-gui/paths.go')
| -rw-r--r-- | gui/cmd/krino-gui/paths.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gui/cmd/krino-gui/paths.go b/gui/cmd/krino-gui/paths.go new file mode 100644 index 0000000..447fc15 --- /dev/null +++ b/gui/cmd/krino-gui/paths.go @@ -0,0 +1,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)) + } +} |
