rss-dl/structs/config.go

33 lines
576 B
Go
Raw Normal View History

2019-04-20 22:30:42 +03:00
package structs
import (
"flag"
"fmt"
"os"
)
// Config - Runtime configuration
var Config struct {
FeedURL string
OutputPath string
2021-06-08 23:43:32 +03:00
ParseHtml bool
2019-04-20 22:30:42 +03:00
}
// GetConfig - Returns Config object
func GetConfig() {
outputPath := flag.String("output", ".", "Output path")
2021-06-08 23:43:32 +03:00
parseHtml := flag.Bool("parsehtml", false, "Save content as html")
2019-04-20 22:30:42 +03:00
flag.Parse()
args := flag.Args()
if len(args) < 1 {
fmt.Println("Usage: rss-dl [OPTIONS] FEED_URL")
os.Exit(2)
}
Config.FeedURL = flag.Args()[len(args)-1]
Config.OutputPath = *outputPath
2021-06-08 23:43:32 +03:00
Config.ParseHtml = *parseHtml
2019-04-20 22:30:42 +03:00
}