Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ klog is a plain-text file format and a command line tool for time tracking.
If you have questions, feedback, feature ideas, or want to report something that’s not working properly,
feel invited to [start a discussion](https://github.com/jotaen/klog/discussions).

If you’d like to contribute code, please discuss your intended change beforehand. Please refrain from submitting unsolicited pull requests.
If you’d like to contribute code, please discuss your intended change beforehand. Please refrain from submitting pull requests proactively.

## About

Expand Down
11 changes: 4 additions & 7 deletions klog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package main
import (
_ "embed"
"fmt"
"os"
"runtime"

"github.com/jotaen/klog/klog/app"
"github.com/jotaen/klog/klog/app/cli/util"
"github.com/jotaen/klog/klog/app/main"
"os"
"runtime"
)

//go:embed Specification.md
Expand Down Expand Up @@ -41,11 +42,7 @@ func main() {
}()

config := func() app.Config {
c, err := app.NewConfig(
app.FromDeterminedValues{NumCpus: runtime.NumCPU()},
app.FromEnvVars{GetVar: os.Getenv},
app.FromConfigFile{FileContents: configFile},
)
c, err := app.NewConfig(runtime.NumCPU(), os.Getenv, configFile)
if err != nil {
fail(util.PrettifyAppError(err, false), app.CONFIG_ERROR.ToInt())
}
Expand Down
7 changes: 4 additions & 3 deletions klog/app/cli/config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package cli

import (
"path/filepath"
"strings"

"github.com/jotaen/klog/klog/app"
tf "github.com/jotaen/klog/klog/app/cli/terminalformat"
"github.com/jotaen/klog/klog/app/cli/util"
"path/filepath"
"strings"
)

type Config struct {
Expand All @@ -27,7 +28,7 @@ klog relies on file-based configuration to customise some of its default behavio

Run 'klog config --location' to print the path of the folder where klog looks for the configuration.
The config folder can contain one or both of the following files:
- '` + 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.
- '` + 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 valid .ini syntax.
- '` + 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.

You can customise the location of the config folder via environment variables. klog uses the following lookup precedence:
Expand Down
7 changes: 4 additions & 3 deletions klog/app/cli/testcontext_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cli

import (
gotime "time"

"github.com/jotaen/klog/klog"
"github.com/jotaen/klog/klog/app"
"github.com/jotaen/klog/klog/app/cli/command"
tf "github.com/jotaen/klog/klog/app/cli/terminalformat"
"github.com/jotaen/klog/klog/parser"
"github.com/jotaen/klog/klog/parser/reconciling"
"github.com/jotaen/klog/klog/parser/txt"
gotime "time"
)

func NewTestingContext() TestingContext {
Expand Down Expand Up @@ -63,11 +64,11 @@ func (ctx TestingContext) _SetFileExplorers(cs []command.Command) TestingContext
}

func (ctx TestingContext) _SetFileConfig(configFile string) TestingContext {
fileCfg := app.FromConfigFile{FileContents: configFile}
err := fileCfg.Apply(ctx.config)
cfg, err := app.NewConfig(1, func(_ string) string { return "" }, configFile)
if err != nil {
panic(err)
}
ctx.config = &cfg
return ctx
}

Expand Down
Loading