Skip to content

Commit

Permalink
cmd: consistent "." vs "" in path return value, log loaded config path
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Jan 3, 2025
1 parent 64febb9 commit c5eba28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cmd/hostd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,15 @@ func runRecalcCommand(srcPath string, log *zap.Logger) error {
}

func main() {
log := initStdoutLog(cfg.Log.StdOut.EnableANSI, cfg.Log.Level)
defer log.Sync()

// attempt to load the config file, command line flags will override any
// values set in the config file
configPath := tryLoadConfig()
if configPath != "" {
log.Info("loaded config file", zap.String("path", configPath))
}
// set the data directory to the default if it is not set
cfg.Directory = defaultDataDirectory(cfg.Directory)

Expand Down Expand Up @@ -334,7 +340,6 @@ func main() {
fmt.Println("hostd", build.Version())
fmt.Println("Commit:", build.Commit())
fmt.Println("Build Date:", build.Time())

case seedCmd:
if len(cmd.Args()) != 0 {
cmd.Usage()
Expand All @@ -360,9 +365,6 @@ func main() {
return
}

log := initStdoutLog(cfg.Log.StdOut.EnableANSI, cfg.Log.Level)
defer log.Sync()

checkFatalError("command failed", runRecalcCommand(cmd.Arg(0), log))
case sqlite3Cmd:
cmd.Usage()
Expand Down
2 changes: 1 addition & 1 deletion cmd/hostd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func defaultDataDirectory(fp string) string {
case "linux", "freebsd", "openbsd":
return filepath.Join(string(filepath.Separator), "var", "lib", "hostd")
default:
return "."
return ""
}
}

Expand Down

0 comments on commit c5eba28

Please sign in to comment.