intake/cmd/serve.go

32 lines
624 B
Go
Raw Permalink Normal View History

2025-01-21 16:42:59 +00:00
package cmd
import (
2025-01-24 00:18:41 +00:00
"github.com/Jaculabilis/intake/web"
2025-01-21 16:42:59 +00:00
"github.com/spf13/cobra"
)
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Serve the web interface",
2025-01-24 00:18:41 +00:00
Long: `Serve the intake web interface.
2025-01-21 16:42:59 +00:00
`,
Run: func(cmd *cobra.Command, args []string) {
2025-01-24 15:15:54 +00:00
serve()
2025-01-21 16:42:59 +00:00
},
}
2025-01-24 15:15:54 +00:00
var serveAddr string
var servePort string
2025-01-21 16:42:59 +00:00
func init() {
rootCmd.AddCommand(serveCmd)
2025-01-24 15:15:54 +00:00
serveCmd.Flags().StringVarP(&serveAddr, "addr", "a", "localhost", "Address to bind to")
serveCmd.Flags().StringVarP(&servePort, "port", "p", "8081", "Port to bind to")
}
func serve() {
db := openAndMigrateDb()
web.RunServer(db, serveAddr, servePort)
2025-01-21 16:42:59 +00:00
}