diff --git a/README.md b/README.md index f5f1578..70ff5d0 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ weather_latitude: 37.77 weather_longitude: 122.41 terminal_mode: false opml_file_path: +markdown_file_prefix: +markdown_file_suffix: ``` ### Command line Options Run matcha with --help option to see current cli options: diff --git a/config.go b/config.go index e20f048..d9bc0fa 100644 --- a/config.go +++ b/config.go @@ -29,7 +29,9 @@ instapaper: true weather_latitude: 37.77 weather_longitude: 122.41 terminal_mode: false -opml_file_path: ` +opml_file_path: +markdown_file_prefix: +markdown_file_suffix: ` func parseOPML(xmlContent []byte) []RSS { o := Opml{} @@ -97,6 +99,12 @@ func bootstrapConfig() { if viper.IsSet("weather_longitude") { lon = viper.Get("weather_longitude").(float64) } + if viper.IsSet("markdown_file_prefix") { + mdPrefix = viper.Get("markdown_file_prefix").(string) + } + if viper.IsSet("markdown_file_suffix") { + mdSuffix = viper.Get("markdown_file_suffix").(string) + } var limit int for _, feed := range feeds.([]any) { @@ -163,7 +171,8 @@ func bootstrapConfig() { check(err) if !terminal_mode { - err := os.Remove(filepath.Join(markdown_dir_path, currentDate+".md")) + markdown_file_name := mdPrefix + currentDate + mdSuffix + ".md" + err := os.Remove(filepath.Join(markdown_dir_path, markdown_file_name)) if err != nil { // fmt.Println("INFO: Coudn't remove old file: ", err) } diff --git a/main.go b/main.go index aa33e0b..7bf8746 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( ) var markdown_dir_path string +var mdPrefix, mdSuffix string var terminal_mode bool = false var currentDate = time.Now().Format("2006-01-02") var lat, lon float64 @@ -81,7 +82,8 @@ func writeToMarkdown(body string) { if terminal_mode { fmt.Println(body) } else { - f, err := os.OpenFile(filepath.Join(markdown_dir_path, currentDate+".md"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + markdown_file_name := mdPrefix + currentDate + mdSuffix + ".md" + f, err := os.OpenFile(filepath.Join(markdown_dir_path, markdown_file_name), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { log.Fatal(err) }