From 6683d9089d0de13c0709f4092f95592c3046a67d Mon Sep 17 00:00:00 2001 From: siddharth Date: Mon, 13 Dec 2021 21:39:53 -0500 Subject: config/config.go: add docs. --- config/config.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 360d9a6..6d9ceaf 100644 --- a/config/config.go +++ b/config/config.go @@ -14,12 +14,18 @@ import ( "ricketyspace.net/fern/file" ) +// Represents the fern config type FernConfig struct { - YDLPath string `json:"ydl-path"` - DumpDir string `json:"dump-dir"` - Feeds []feed.Feed `json:"feeds"` + YDLPath string `json:"ydl-path"` // Path to the youtube-dl program. + DumpDir string `json:"dump-dir"` // Path where media needs to be downloaded to. + Feeds []feed.Feed `json:"feeds"` // Feeds to download. } +// Tries to reads the fern config at `$HOME/.config/fern/fern.json` +// and unmarshals it into `FernConfig` +// +// Returns point to `FernConfig` on success. On error, the returned +// config is `nil` and the returned error is non-nil. func Read() (*FernConfig, error) { // Construct config file path. h, err := os.UserHomeDir() @@ -55,6 +61,9 @@ func Read() (*FernConfig, error) { return config, nil } +// Validates the FernConfig. +// +// Returns nil if validation succeeds; error otherwise. func (config *FernConfig) validate() error { // Validate 'ydl-path' in config. if len(config.YDLPath) == 0 { -- cgit v1.2.3