Skip to content

Commit

Permalink
Add stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jafarlihi committed Nov 19, 2022
1 parent f5099f0 commit cb66fc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 14 additions & 8 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import (
)

var defaultConfigContent = `[settings]
feed_directory = ~/rssnix
viewer = vim
max_concurrent_fetch = 5
feed_directory = ~/rssnix
[feeds]`

type Config struct {
FeedDirectory string
Viewer string
MaxConcurrentFetch int
Feeds []Feed
type Configuration struct {
FeedDirectory string
Viewer string
Feeds []Feed
}

var Config Configuration

func LoadConfig() {
homePath, err := os.UserHomeDir()
if err != nil {
Expand Down Expand Up @@ -50,5 +50,11 @@ func LoadConfig() {
}

cfg, err := ini.Load(homePath + "/.config/rssnix/config.ini")
log.Info(cfg)

Config = Configuration{}
Config.FeedDirectory = cfg.Section("settings").Key("feed_directory").String()
Config.Viewer = cfg.Section("settings").Key("viewer").String()
for _, key := range cfg.Section("feeds").Keys() {
Config.Feeds = append(Config.Feeds, Feed{key.String(), cfg.Section("feeds").Key(key.String()).String()})
}
}
3 changes: 1 addition & 2 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[settings]
feed_directory = ~/rssnix
viewer = vim
max_concurrent_fetch = 5
feed_directory = ~/rssnix

[feeds]
CNN-Tech = http://rss.cnn.com/rss/edition_technology.rss
Expand Down

0 comments on commit cb66fc0

Please sign in to comment.