Initial commit

This commit is contained in:
2020-10-17 14:30:30 +01:00
commit 3e8c5dbd6b
19 changed files with 1576 additions and 0 deletions

26
cmd/refresh.go Normal file
View File

@@ -0,0 +1,26 @@
package cmd
import (
"github.com/averagemarcus/gopherss/internal/feeds"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var refreshCmd = &cobra.Command{
Use: "refresh",
Short: "Refreshes all feeds",
RunE: func(cmd *cobra.Command, args []string) error {
return feeds.Refresh()
},
}
var (
interval int
)
func init() {
refreshCmd.Flags().IntVar(&interval, "interval", 15, "How long in minutes to wait before refreshing feeds")
viper.BindPFlag("refreshTimeoutMinutes", refreshCmd.Flags().Lookup("interval"))
rootCmd.AddCommand(refreshCmd)
}

20
cmd/root.go Normal file
View File

@@ -0,0 +1,20 @@
package cmd
import (
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "gopherss",
Short: "An RSS reader written in Go",
RunE: func(cmd *cobra.Command, args []string) error {
go refreshCmd.RunE(cmd, args)
return serverCmd.RunE(cmd, args)
},
}
)
func Execute() error {
return rootCmd.Execute()
}

25
cmd/server.go Normal file
View File

@@ -0,0 +1,25 @@
package cmd
import (
"github.com/spf13/cobra"
"github.com/averagemarcus/gopherss/internal/server"
)
var (
port string
)
var serverCmd = &cobra.Command{
Use: "server",
Short: "Starts the web server",
RunE: func(cmd *cobra.Command, args []string) error {
return server.Start(port)
},
}
func init() {
serverCmd.Flags().StringVarP(&port, "port", "p", "8080", "The port to run the web server on")
rootCmd.AddCommand(serverCmd)
}