Skip to content

Commit 77382ad

Browse files
committed
Print config path
1 parent 9344913 commit 77382ad

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

internal/application/config.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ import (
1111
"github.com/tailscale/hujson"
1212
)
1313

14-
func LoadConfig() (*Config, error) {
14+
func LoadConfig() (*Config, string, error) {
1515
path, err := FindConfigPath()
1616
if err != nil {
17-
return nil, err
17+
return nil, "", err
18+
}
19+
20+
cfg, err := LoadConfigAt(path)
21+
if err != nil {
22+
return nil, "", err
1823
}
1924

20-
return LoadConfigAt(path)
25+
return cfg, path, nil
2126
}
2227

2328
func LoadConfigAt(path string) (*Config, error) {
@@ -108,10 +113,6 @@ func FindConfigPath() (string, error) {
108113
add(filepath.Join(cfgDir, "migrate", name))
109114
}
110115

111-
if home, err := os.UserHomeDir(); err == nil {
112-
add(filepath.Join(home, name))
113-
}
114-
115116
var errs []error
116117
for _, path := range candidates {
117118
info, err := os.Stat(path)

internal/application/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestLoadConfig(t *testing.T) {
2828
_ = os.Remove(configPath)
2929
})
3030

31-
cfg, err := LoadConfig()
31+
cfg, _, err := LoadConfig()
3232
assert.NilError(t, err)
3333

3434
assert.Equal(t, cfg.StorageService.API.URL, "http://localhost:62081")

internal/cmd/rootcmd/rootcmd.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ func (cfg *RootConfig) App(ctx context.Context) (*application.App, error) {
8888
}
8989

9090
func (cfg *RootConfig) initApp(ctx context.Context) (*application.App, error) {
91-
config, err := application.LoadConfig()
91+
config, path, err := application.LoadConfig()
9292
if err != nil {
9393
return nil, err
9494
}
9595

96+
cfg.Logger().Info("Loaded config.", slog.String("path", path))
97+
9698
db, err := initDatabase(ctx, config.Database.SQLite.Path)
9799
if err != nil {
98100
return nil, err

0 commit comments

Comments
 (0)