Skip to content

Commit 89c726f

Browse files
committed
refactor: simplify the implementation
Call ReadConfig, since it already does the majority of work
1 parent 7b2554a commit 89c726f

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

internal/config/config.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,9 @@ func ReadConfig() (*Config, error) {
3232
}
3333

3434
func PrintConfig() {
35-
path := getConfigPathOrDefault()
36-
file, err := os.ReadFile(path)
35+
config, err := ReadConfig()
3736
if err != nil {
38-
fmt.Fprintln(os.Stderr, "Error reading the config")
39-
os.Exit(1)
40-
}
41-
42-
var config Config
43-
if err := yaml.Unmarshal(file, &config); err != nil {
44-
fmt.Fprintln(os.Stderr, "Error parsing the config")
37+
fmt.Fprintf(os.Stderr, "Error reading config %v\n", err)
4538
os.Exit(1)
4639
}
4740

0 commit comments

Comments
 (0)