blasphem/pkg/cmd/serve/cmd.go
2022-12-20 19:05:45 -05:00

48 lines
805 B
Go

package serve
import (
"dynatron.me/x/blasphem/internal/common"
blas "dynatron.me/x/blasphem/pkg/blas/core"
"dynatron.me/x/blasphem/pkg/server"
"github.com/spf13/cobra"
)
type ServeOptions struct {
core blas.Blas
}
func Command(core blas.Blas) *cobra.Command {
opts := makeOptions(core)
serveCmd := &cobra.Command{
Use: "serve",
Short: "starts the " + common.AppName + " server",
RunE: common.RunE(opts),
}
return serveCmd
}
func makeOptions(core blas.Blas) *ServeOptions {
return &ServeOptions{
core: core,
}
}
func (o *ServeOptions) Options(_ *cobra.Command, args []string) error {
return nil
}
func (o *ServeOptions) Execute() error {
server, err := server.New(o.core)
if err != nil {
return err
}
err = server.Go()
if err != nil {
return err
}
return nil
}