Skip to content

Commit

Permalink
fix: optional config file (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulb authored Dec 18, 2024
1 parent ffe38e3 commit 9524021
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package ecdysis

import (
"fmt"
"os"
"reflect"
"strings"

Expand Down Expand Up @@ -86,7 +87,10 @@ func parseConfig(v *viper.Viper, cfg Config, cmd *cobra.Command) error {
// Handle config file
v.SetConfigFile(cfg.Path)
if err := v.ReadInConfig(); err != nil {
return fmt.Errorf("fatal error config file: %w", err)
// we make the existence of the config file optional
if !os.IsNotExist(err) {
return fmt.Errorf("fatal error config file: %w", err)
}
}

var errors []error
Expand Down

0 comments on commit 9524021

Please sign in to comment.