add scraping the torrent topics rss files
This commit is contained in:
55
internal/flag.go
Normal file
55
internal/flag.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const usage = `Music Database (MDB) server/cli craftware'
|
||||
|
||||
Usage:
|
||||
mdb [command] -c [config-file-path]
|
||||
|
||||
Commands:
|
||||
-help, -h Print this message
|
||||
-version -v Print version.
|
||||
-config -c Set configuration file without extension. It is %s by default.
|
||||
-section -s Select section e.g.: rutracker, bandcamp etc.
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
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", "", "")
|
||||
|
||||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
||||
pflag.Parse()
|
||||
err := viper.BindPFlags(pflag.CommandLine)
|
||||
if err != nil {
|
||||
log.Fatalf("[ERR] Failed to bind flags to config: %s", err)
|
||||
}
|
||||
|
||||
if viper.GetBool("h") || viper.GetBool("help") {
|
||||
msg := fmt.Sprintf(usage, defaultConfigPath, runtime.Version())
|
||||
fmt.Println(msg)
|
||||
} else if viper.GetBool("v") || viper.GetBool("version") {
|
||||
fmt.Println("MDB version", version)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user