Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,17 @@ func (o *Options) loadConfigFile(configFilePath string, label string) {
// if noConf is true, only a config file set via option --conf will be parsed.
func (o *Options) LoadConfigs(noConf bool, configFileArg string) {
if !noConf {
if runtime.GOOS != "windows" {
// load system wide config if file exists
if _, err := os.Stat("/etc/sift.conf"); err == nil {
o.loadConfigFile("/etc/sift.conf", "system config")
}
}
// load config from global sift config if file exists
if homedir := getHomeDir(); homedir != "" {
configFilePath := filepath.Join(homedir, SiftConfigFile)
if _, err := os.Stat(configFilePath); err == nil {
o.loadConfigFile(configFilePath, "global config")
o.loadConfigFile(configFilePath, "user config")
}
}

Expand Down Expand Up @@ -703,9 +709,13 @@ func (o *Options) checkCompatibility(patterns []string, targets []string) error
// processConfigOptions processes the options --print-config and --write-config
func (o *Options) processConfigOptions() error {
if o.PrintConfig {
if runtime.GOOS != "windows" {
// load system wide config if file exists
fmt.Fprintf(os.Stderr, "System config file path: %s\n", "/etc/sift.conf")
}
if homedir := getHomeDir(); homedir != "" {
globalConfigFilePath := filepath.Join(homedir, SiftConfigFile)
fmt.Fprintf(os.Stderr, "Global config file path: %s\n", globalConfigFilePath)
fmt.Fprintf(os.Stderr, "User config file path: %s\n", globalConfigFilePath)
} else {
errorLogger.Println("could not detect user home directory.")
}
Expand Down