Bind port to env var

This commit is contained in:
Marcus Noble 2020-10-17 21:20:10 +01:00
parent f5c2b1952a
commit caf32c1c3a

View File

@ -2,6 +2,7 @@ package cmd
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/averagemarcus/gopherss/internal/server" "github.com/averagemarcus/gopherss/internal/server"
) )
@ -20,6 +21,7 @@ var serverCmd = &cobra.Command{
func init() { func init() {
serverCmd.Flags().StringVarP(&port, "port", "p", "8080", "The port to run the web server on") serverCmd.Flags().StringVarP(&port, "port", "p", "8080", "The port to run the web server on")
viper.BindPFlag("PORT", refreshCmd.Flags().Lookup("port"))
rootCmd.AddCommand(serverCmd) rootCmd.AddCommand(serverCmd)
} }