package cmd import ( "github.com/Jaculabilis/intake/web" "github.com/spf13/cobra" ) var serveCmd = &cobra.Command{ Use: "serve", Short: "Serve the web interface", Long: `Serve the intake web interface. `, Run: func(cmd *cobra.Command, args []string) { serve(stringArg(cmd, "addr"), stringArg(cmd, "port")) }, } func init() { rootCmd.AddCommand(serveCmd) serveCmd.Flags().StringP("addr", "a", "localhost", "Address to bind to") serveCmd.Flags().StringP("port", "p", "8081", "Port to bind to") } func serve(addr string, port string) { db := openAndMigrateDb() web.RunServer(db, addr, port) }