preset scraper added

This commit is contained in:
2024-09-10 15:57:48 +03:00
parent bfdfc634e4
commit 0ecf0ddec1
38 changed files with 790 additions and 167 deletions

View File

@@ -8,6 +8,8 @@ import (
"github.com/spf13/pflag"
"github.com/spf13/viper"
"git.amok.space/yevhen/resource-scraper/types/constant"
)
const usage = `Music Database (MDB) server/cli craftware'
@@ -25,19 +27,18 @@ The Go runtime version: %s
Report bugs to https://git.amok.space/yevhen/resource-scraper/issues`
const (
maxPasswordLength = 20
version = "0.1"
defaultConfigPath = "./config/default"
defaultConfigPath = "config/default"
)
func ParseFlags() {
flag.Bool("h", false, "")
flag.Bool("help", false, "")
flag.Bool("v", false, "")
flag.Bool("version", false, "")
flag.Bool("debug", false, "")
flag.String("config-file", defaultConfigPath, "config file location used for the program")
flag.String("scope", "", "")
flag.Bool(constant.FlagHelpShort, false, "")
flag.Bool(constant.FlagHelp, false, "")
flag.Bool(constant.FlagVersionShort, false, "")
flag.Bool(constant.FlagVersion, false, "")
flag.Bool(constant.FlagDebug, false, "")
flag.String(constant.FlagConfigFile, defaultConfigPath, "config file location used for the program")
flag.String(constant.FlagScopeEnable, "", "")
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
@@ -46,10 +47,10 @@ func ParseFlags() {
log.Fatalf("[ERR] Failed to bind flags to config: %s", err)
}
if viper.GetBool("h") || viper.GetBool("help") {
if viper.GetBool(constant.FlagHelpShort) || viper.GetBool(constant.FlagHelp) {
msg := fmt.Sprintf(usage, defaultConfigPath, runtime.Version())
fmt.Println(msg)
} else if viper.GetBool("v") || viper.GetBool("version") {
} else if viper.GetBool(constant.FlagVersionShort) || viper.GetBool(constant.FlagVersion) {
fmt.Println("MDB version", version)
}
}