dyndns/cmd/serve.go
Torben Nehmer 9952343cda Cleaned up config handling
- moved everything to cmd/root.go
- Sanitize all paths to full absolute ones
- Set a config key with the current config basedir
- moved default config logging to a central location
- resolve user config dir relative to config dir
- change cwd to config dir
2021-08-25 21:17:19 +02:00

26 lines
591 B
Go

package cmd
import (
"gitea.nehmer.net/torben/dyndns/service"
"gitea.nehmer.net/torben/dyndns/webapi"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var cmdServe = &cobra.Command{
Use: "server",
Short: "Start webserver",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
webapi.LoadConfig()
service.LoadConfig()
webapi.Server()
},
}
func init() {
rootCmd.AddCommand(cmdServe)
cmdServe.Flags().StringP("ListenAddress", "l", "", "ListenAddress for the application server")
viper.BindPFlag("WebAPI.ListenAddress", cmdServe.Flags().Lookup("ListenAddress"))
}