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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"fmt"
"io"
"krino/internal/config"
"krino/internal/xdg"
)
func init() { commands["init"] = cmdInit }
// cmdInit creates the config directory with a commented krino.conf and
// template.conf.
func cmdInit(g *globals, args []string, stdout, stderr io.Writer) int {
fs := flagSet("init", g)
if code, ok := parse(fs, args, stdout, stderr); !ok {
return code
}
if fs.NArg() != 0 {
return usageError(stderr, "init takes no arguments")
}
created, err := config.Init(mainFile(g))
if err != nil {
fmt.Fprintf(stderr, "krino: %v\n", err)
return 2
}
for _, f := range created {
fmt.Fprintf(stdout, "created %s\n", xdg.Abbrev(f))
}
fmt.Fprintln(stdout, "next: krino new NAME PATH, for example: krino new downloads ~/Downloads")
return 0
}
|