Skip to content

Commit 2801a6c

Browse files
committed
Consolidate config folder docs
1 parent 7b3cc55 commit 2801a6c

File tree

4 files changed

+46
-57
lines changed

4 files changed

+46
-57
lines changed

klog/app/cli/bookmarks.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ A bookmark name is denoted by the prefix '@'. For example, if you have a bookmar
3535
klog edit @work
3636
3737
You can specify as many bookmarks as you want. There can also be one “unnamed” default bookmark (which internally is identified by the name '@default').
38-
This is useful in case you only have one main file at a time, and allows you to use klog without any input arguments at all. E.g.:
38+
This is useful in case you only have one main file at a time, and allows you to use klog without any file-related input arguments at all. E.g.:
3939
4040
klog total
4141
klog start --summary 'Started new project'
4242
43-
When creating a bookmark, you can also create the respective target file by using the '--create' flag.
43+
When setting up a bookmark, you can also create the respective target file on the file system by using the '--create' flag.
44+
45+
Note that klog keeps track of the bookmarks in an internal config file. Run 'klog config --help' to learn more.
4446
`
4547
}
4648

klog/app/cli/config.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,45 @@ import (
44
"github.com/jotaen/klog/klog/app"
55
tf "github.com/jotaen/klog/klog/app/cli/terminalformat"
66
"github.com/jotaen/klog/klog/app/cli/util"
7+
"path/filepath"
8+
"strings"
79
)
810

911
type Config struct {
1012
util.NoStyleArgs
13+
Location bool `name:"location" help:"Print the location of the config folder."`
1114
}
1215

1316
func (opt *Config) Help() string {
17+
lookupOrder := func() string {
18+
lookups := make([]string, len(app.KLOG_CONFIG_FOLDER))
19+
for i, f := range app.KLOG_CONFIG_FOLDER {
20+
lookups[i] = filepath.Join(f.EnvVarSymbol(), f.Location)
21+
}
22+
return strings.Join(lookups, " -> ")
23+
}()
24+
1425
return `
15-
You are able to configure some of klog’s behaviour by providing a configuration file.
26+
klog relies on file-based configuration to customise some of its default behaviour and to keep track of its internal state.
1627
17-
If you run 'klog config', you can learn about the supported properties in the file, and which of those you have set.
18-
You may use the output of that command as template for setting up your config file, as its format is valid syntax.
28+
Run 'klog config --location' to print the path of the folder where klog looks for the configuration.
29+
The config folder can contain one or both of the following files:
30+
- '` + app.CONFIG_FILE_NAME + `': you can create this file manually to override some of klog’s default behaviour. You may use the output of the 'klog config' command as template for setting up this file, as its output is in valid syntax.
31+
- '` + app.BOOKMARKS_FILE_NAME + `': if you use the bookmarks functionality, then klog uses this file as database. You are not supposed to edit this file by hand! Instead, use the 'klog bookmarks' command to manage your bookmarks.
1932
20-
The configuration file is named 'config.ini' and resides in your klog config folder.
21-
Run 'klog info config-folder' to learn where your klog config folder is located.
33+
You can customise the location of the config folder via environment variables. klog uses the following lookup precedence:
34+
` + lookupOrder + `
2235
`
2336
}
2437

2538
func (opt *Config) Run(ctx app.Context) app.Error {
2639
opt.NoStyleArgs.Apply(&ctx)
40+
41+
if opt.Location {
42+
ctx.Print(ctx.KlogConfigFolder().Path() + "\n")
43+
return nil
44+
}
45+
2746
styler, _ := ctx.Serialise()
2847
for i, e := range app.CONFIG_FILE_ENTRIES {
2948
ctx.Print(styler.Props(tf.StyleProps{Color: tf.TEXT_SUBDUED}).Format(util.Reflower.Reflow(e.Help.Summary, []string{"# "})))

klog/app/cli/index.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
kc "github.com/jotaen/kong-completion"
99
)
1010

11+
var INTRO_SUMMARY = "command-line tool for time tracking in a human-readable, plain-text file format.\nSee " + KLOG_WEBSITE_URL + " for documentation."
12+
1113
// Guideline for help texts and descriptions:
1214
// - Command and flag descriptions are phrased in imperative style, and they
1315
// end in a period. Examples:
@@ -55,10 +57,10 @@ type Default struct {
5557

5658
func (opt *Default) Help() string {
5759
return `
58-
klog: command line app for time tracking with plain-text files. See also ` + KLOG_WEBSITE_URL + `
60+
klog is ` + INTRO_SUMMARY + `
5961
6062
Time-tracking data is stored in files ending in the '.klg' extension.
61-
You can use the subcommands below to evaluate, manipulate and manage your files.
63+
You can use the subcommands listed below to evaluate, manipulate and manage your files.
6264
Use the '--help' flag on the subcommands to learn more.
6365
6466
You can specify input data in one of these 3 ways:
@@ -80,7 +82,7 @@ func (opt *Default) Run(ctx app.Context) app.Error {
8082
versionCmd := Version{}
8183
return versionCmd.Run(ctx)
8284
}
83-
ctx.Print("klog: command line app for time tracking with plain-text files.\n")
85+
ctx.Print("klog: " + INTRO_SUMMARY + "\n")
8486
ctx.Print("Run 'klog --help' to learn usage.\n")
8587
return nil
8688
}

klog/app/cli/info.go

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,24 @@ package cli
22

33
import (
44
"github.com/jotaen/klog/klog/app"
5-
"github.com/jotaen/klog/klog/app/cli/util"
6-
"path/filepath"
7-
"strings"
85
)
96

107
type Info struct {
11-
Spec InfoSpec `cmd:"" name:"spec" help:"Print the .klg file format specification."`
12-
License InfoLicense `cmd:"" name:"license" help:"Print license / copyright information."`
13-
ConfigFolder InfoConfigFolder `cmd:"" name:"config-folder" help:"Print the path of the klog config folder."`
8+
Spec bool `name:"spec" help:"Print the .klg file format specification."`
9+
License bool `name:"license" help:"Print license / copyright information."`
10+
About bool `name:"about" help:"Print meta information about klog."`
1411
}
1512

16-
func (opt *Info) Help() string {
17-
return `
18-
Run 'klog info config-folder' to see the location of your klog config folder.
19-
The location of the config folder depends on your operating system and environment settings.
20-
You can customise the folder’s location via environment variables – run the command to learn which ones klog relies on.
21-
22-
The config folder is used to store two files:
23-
- 'config.ini' (optional) – you can create this file manually to override some of klog’s default behaviour. Run 'klog config' to learn more.
24-
- 'bookmarks.json' (optional) – if you use bookmarks, then klog uses this file as database. You are not supposed to edit this file by hand! Instead, use the 'klog bookmarks' command to manage your bookmarks.
25-
26-
Run 'klog info spec' to read the formal specification of the klog file format.
27-
If you want to review klog’s license and copyright information, run 'klog info license'.
28-
`
29-
}
30-
31-
type InfoConfigFolder struct {
32-
util.QuietArgs
33-
}
34-
35-
func (opt *InfoConfigFolder) Run(ctx app.Context) app.Error {
36-
ctx.Print(ctx.KlogConfigFolder().Path() + "\n")
37-
if !opt.Quiet {
38-
lookups := make([]string, len(app.KLOG_CONFIG_FOLDER))
39-
for i, f := range app.KLOG_CONFIG_FOLDER {
40-
lookups[i] = filepath.Join(f.EnvVarSymbol(), f.Location)
41-
}
42-
ctx.Print("(Lookup order: " + strings.Join(lookups, ", ") + ")\n")
13+
func (opt *Info) Run(ctx app.Context) app.Error {
14+
//ctx.Print(ctx.KlogConfigFolder().Path() + "\n")
15+
if opt.Spec {
16+
ctx.Print(ctx.Meta().Specification + "\n")
17+
} else if opt.License {
18+
ctx.Print(ctx.Meta().License + "\n")
19+
} else if opt.About {
20+
ctx.Print("klog is a " + INTRO_SUMMARY + "\n")
21+
} else {
22+
ctx.Print("Use --spec or --license\n")
4323
}
4424
return nil
4525
}
46-
47-
type InfoSpec struct{}
48-
49-
func (opt *InfoSpec) Run(ctx app.Context) app.Error {
50-
ctx.Print(ctx.Meta().Specification + "\n")
51-
return nil
52-
}
53-
54-
type InfoLicense struct{}
55-
56-
func (opt *InfoLicense) Run(ctx app.Context) app.Error {
57-
ctx.Print(ctx.Meta().License + "\n")
58-
return nil
59-
}

0 commit comments

Comments
 (0)