mirror of
https://github.com/pikami/rss-dl.git
synced 2025-12-22 02:20:03 +00:00
Added configuration flags
This commit is contained in:
29
structs/config.go
Normal file
29
structs/config.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package structs
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Config - Runtime configuration
|
||||
var Config struct {
|
||||
FeedURL string
|
||||
OutputPath string
|
||||
}
|
||||
|
||||
// GetConfig - Returns Config object
|
||||
func GetConfig() {
|
||||
outputPath := flag.String("output", ".", "Output path")
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user