~chrisppy/beagles

6ec0c88929d2c3be34d71071bf5db82cfcd493fc — Chris Palmer 24 days ago ed7d1da
Cleanup config
2 files changed, 30 insertions(+), 23 deletions(-)

M config/config.go
M ui/ui.go
M config/config.go => config/config.go +28 -21
@@ 29,9 29,8 @@ import (

// Config contains all relevant configuration data for the application
type Config struct {
	ExtPlayer      *ExternalPlayer
	Browser        *Browser
	AutoDownload   bool
	Podcast        Podcast
	ErrColor       tcell.Color
	SeparatorColor tcell.Color
	ReadColor      tcell.Color


@@ 82,21 81,20 @@ type KeyCMD struct {
}

type config struct {
	BackgroundColor string          `toml:"background_color"`
	ForegroundColor string          `toml:"foreground_color"`
	ErrorColor      string          `toml:"error_color"`
	Separator       string          `toml:"separator_color"`
	ReadColor       string          `toml:"read_color"`
	AutoDownload    bool            `toml:"auto_download"`
	KeyCommands     keyCommands     `toml:"key_commands"`
	Browser         *Browser        `toml:"browser, omitempty"`
	ExternalPlayer  *ExternalPlayer `toml:"external_player, omitempty"`
	CommandLine     *commandLine    `toml:"command_line, omitempty"`
	StatusLine      *statusLine     `toml:"status_line, omitempty"`
	TitleLine       *titleLine      `toml:"title_line, omitempty"`
	List            *list           `toml:"list, omitempty"`
	Content         *content        `toml:"content, omitempty"`
	Tree            *tree           `toml:"tree, omitempty"`
	BackgroundColor string       `toml:"background_color"`
	ForegroundColor string       `toml:"foreground_color"`
	ErrorColor      string       `toml:"error_color"`
	Separator       string       `toml:"separator_color"`
	ReadColor       string       `toml:"read_color"`
	KeyCommands     keyCommands  `toml:"key_commands"`
	Podcast         Podcast      `toml:"podcast"`
	Browser         *Browser     `toml:"browser, omitempty"`
	CommandLine     *commandLine `toml:"command_line, omitempty"`
	StatusLine      *statusLine  `toml:"status_line, omitempty"`
	TitleLine       *titleLine   `toml:"title_line, omitempty"`
	List            *list        `toml:"list, omitempty"`
	Content         *content     `toml:"content, omitempty"`
	Tree            *tree        `toml:"tree, omitempty"`
}

// KeyCommands config


@@ 119,6 117,12 @@ type keyCommands struct {
	Favorite       string `toml:"favorite"`
}

// Podcast config
type Podcast struct {
	AutoDownload   bool
	ExternalPlayer *ExternalPlayer `toml:"external_player, omitempty"`
}

// ExternalPlayer config
type ExternalPlayer struct {
	Bin  string   `toml:"bin"`


@@ 205,8 209,7 @@ func Load(configDir string) *Config {
	cmds := make(map[string]bool)

	c := &Config{
		AutoDownload:   cfg.AutoDownload,
		ExtPlayer:      cfg.ExternalPlayer,
		Podcast:        cfg.Podcast,
		Browser:        cfg.Browser,
		ErrColor:       tcell.GetColor(cfg.ErrorColor),
		SeparatorColor: tcell.GetColor(cfg.Separator),


@@ 369,18 372,22 @@ func defaultConfig() *config {
		Favorite:       "F",
	}

	pod := Podcast{
		AutoDownload:   true,
		ExternalPlayer: extPlay,
	}

	return &config{
		AutoDownload:    true,
		BackgroundColor: "#88c0d0",
		ForegroundColor: "#2e3440",
		ErrorColor:      "#bf616a",
		Separator:       "#88c0d0",
		ReadColor:       "#b48ead",
		ExternalPlayer:  extPlay,
		CommandLine:     cltheme,
		Content:         cnttheme,
		List:            ltheme,
		Tree:            ttheme,
		KeyCommands:     keys,
		Podcast:         pod,
	}
}

M ui/ui.go => ui/ui.go +2 -2
@@ 420,7 420,7 @@ func (i *UI) updateFeed(args []string) {
			return
		}

		if i.Config.AutoDownload && len(nitems) != 0 {
		if i.Config.Podcast.AutoDownload && len(nitems) != 0 {
			for _, item := range nitems {
				if err := item.Download(i.DownloadPath, i.DB.Feeds); err != nil {
					i.commandLine.setError(err.Error())


@@ 549,7 549,7 @@ func (i *UI) play(event *tcell.EventKey) *tcell.EventKey {
		return event
	}

	ep := i.Config.ExtPlayer
	ep := i.Config.Podcast.ExternalPlayer
	if ep == nil {
		return nil
	}