Generate an RSS feed from a config file and an mp3 file.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.3 KiB

package cmd
import (
var cfgFile string
//GlobalCfg is a struct with all the global configuration available
var GlobalCfg objects.GlobalConfig
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "feeder",
Short: "Generate iTunes-compatible RSS feed generator",
Long: `Generate iTunes-compatible RSS feed generator.`,
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
func init() {
// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" { // enable ability to specify config file via flag
viper.SetConfigName("feeder") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path
viper.AddConfigPath("/usr/local/etc/feeder") // Finally, look in /etc as second search path
viper.SetConfigType("yaml") // or viper.SetConfigType("yaml")
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
GlobalCfg.SourceHost = viper.GetString("podcast_name")
GlobalCfg.SourceHost = viper.GetString("podcast_author")
GlobalCfg.SourceHost = viper.GetString("podcast_link")
GlobalCfg.SourceHost = viper.GetString("podcast_language")
GlobalCfg.SourceHost = viper.GetString("podcast_is_explicit")
GlobalCfg.SourceHost = viper.GetString("podcast_owner")
GlobalCfg.SourceHost = viper.GetString("podcast_owner_email")
GlobalCfg.SourceHost = viper.GetString("podcast_categories")
GlobalCfg.SourceHost = viper.GetString("podcast_copyright")
GlobalCfg.SourceHost = viper.GetString("podcast_type")
GlobalCfg.SourceHost = viper.GetString("podcast_image")
GlobalCfg.SourceHost = viper.GetString("podcast_description")
GlobalCfg.SourceHost = viper.GetString("podcast_items")
} else {
fmt.Printf("Error parsing config! - %v", err)