Skip to content

Commit 27ec2aa

Browse files
committed
Fix config precedence
1 parent 5d83a5b commit 27ec2aa

File tree

4 files changed

+168
-228
lines changed

4 files changed

+168
-228
lines changed

klog.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package main
33
import (
44
_ "embed"
55
"fmt"
6+
"os"
7+
"runtime"
8+
69
"github.com/jotaen/klog/klog/app"
710
"github.com/jotaen/klog/klog/app/cli/util"
811
"github.com/jotaen/klog/klog/app/main"
9-
"os"
10-
"runtime"
1112
)
1213

1314
//go:embed Specification.md
@@ -41,11 +42,7 @@ func main() {
4142
}()
4243

4344
config := func() app.Config {
44-
c, err := app.NewConfig(
45-
app.FromDeterminedValues{NumCpus: runtime.NumCPU()},
46-
app.FromEnvVars{GetVar: os.Getenv},
47-
app.FromConfigFile{FileContents: configFile},
48-
)
45+
c, err := app.NewConfig(runtime.NumCPU(), os.Getenv, configFile)
4946
if err != nil {
5047
fail(util.PrettifyAppError(err, false), app.CONFIG_ERROR.ToInt())
5148
}

klog/app/cli/testcontext_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package cli
22

33
import (
4+
gotime "time"
5+
46
"github.com/jotaen/klog/klog"
57
"github.com/jotaen/klog/klog/app"
68
"github.com/jotaen/klog/klog/app/cli/command"
79
tf "github.com/jotaen/klog/klog/app/cli/terminalformat"
810
"github.com/jotaen/klog/klog/parser"
911
"github.com/jotaen/klog/klog/parser/reconciling"
1012
"github.com/jotaen/klog/klog/parser/txt"
11-
gotime "time"
1213
)
1314

1415
func NewTestingContext() TestingContext {
@@ -63,11 +64,11 @@ func (ctx TestingContext) _SetFileExplorers(cs []command.Command) TestingContext
6364
}
6465

6566
func (ctx TestingContext) _SetFileConfig(configFile string) TestingContext {
66-
fileCfg := app.FromConfigFile{FileContents: configFile}
67-
err := fileCfg.Apply(ctx.config)
67+
cfg, err := app.NewConfig(1, func(_ string) string { return "" }, configFile)
6868
if err != nil {
6969
panic(err)
7070
}
71+
ctx.config = &cfg
7172
return ctx
7273
}
7374

0 commit comments

Comments
 (0)