Xinwei Xiong 02a3cfb021
feat: Introduce Language-Specific Comment Detection Tool and Standardize Log Filename Convention (#1992)
* feat: optimize openim reset code

* feat: optimize openim reset code

* feat: optimize openim reset code

* feat: optimize openim reset code

* feat: optimize openim reset code

* feat: optimize openim reset code

* feat: optimize openim reset code

* feat: optimize openim reset code
2024-03-04 09:30:17 +00:00

36 lines
657 B
Go

package config
import (
"flag"
"log"
"os"
"gopkg.in/yaml.v2"
)
type Config struct {
Directory string `yaml:"directory"`
FileTypes []string `yaml:"file_types"`
Languages []string `yaml:"languages"`
}
func ParseConfig() (Config, error) {
var configPath string
flag.StringVar(&configPath, "config", "./", "Path to config file")
flag.Parse()
var config Config
if configPath != "" {
configFile, err := os.ReadFile(configPath)
if err != nil {
return Config{}, err
}
if err := yaml.Unmarshal(configFile, &config); err != nil {
return Config{}, err
}
} else {
log.Fatal("Config file must be provided")
}
return config, nil
}