blasphem/pkg/cmd/serve/cmd.go
2022-12-20 16:26:04 -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.Core
}
func Command(core blas.Core) *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.Core) *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
}