| skipped 4 lines |
5 | 5 | | |
6 | 6 | | "github.com/bearer/bearer/pkg/commands/artifact" |
7 | 7 | | "github.com/bearer/bearer/pkg/flag" |
| 8 | + | "github.com/bearer/bearer/pkg/util/file" |
8 | 9 | | "github.com/bearer/bearer/pkg/util/output" |
| 10 | + | "github.com/rs/zerolog/log" |
9 | 11 | | "github.com/spf13/cobra" |
10 | 12 | | "github.com/spf13/viper" |
11 | 13 | | "golang.org/x/xerrors" |
| skipped 42 lines |
54 | 56 | | } |
55 | 57 | | |
56 | 58 | | configPath := viper.GetString(flag.ConfigFileFlag.ConfigName) |
| 59 | + | defaultConfigPath := file.GetFullFilename(args[0], configPath) |
57 | 60 | | |
| 61 | + | loadedFile := false |
58 | 62 | | if err := readConfig(configPath); err != nil { |
59 | | - | return err |
| 63 | + | if err := readConfig(defaultConfigPath); err != nil { |
| 64 | + | log.Debug().Msgf("Couldn't find config file %s or %s", configPath, defaultConfigPath) |
| 65 | + | } else { |
| 66 | + | log.Debug().Msgf("Loading default config file %s", defaultConfigPath) |
| 67 | + | loadedFile = true |
| 68 | + | } |
| 69 | + | } else { |
| 70 | + | log.Debug().Msgf("Loading config file %s", configPath) |
| 71 | + | loadedFile = true |
60 | 72 | | } |
61 | 73 | | |
62 | 74 | | options, err := ScanFlags.ToOptions(args) |
| skipped 1 lines |
64 | 76 | | return xerrors.Errorf("flag error: %w", err) |
65 | 77 | | } |
66 | 78 | | |
67 | | - | if !options.Quiet && configPath != "" { |
68 | | - | output.StdErrLogger().Msgf("Loaded %s configuration file", configPath) |
| 79 | + | if !options.Quiet && loadedFile { |
| 80 | + | output.StdErrLogger().Msgf("Loaded configuration file") |
69 | 81 | | } |
70 | 82 | | |
71 | 83 | | output.Setup(cmd, options) |
| skipped 33 lines |