reCoreD-UI/cmd/server/server.go
2024-04-19 09:44:37 +08:00

40 lines
695 B
Go

package server
import (
webserver "reCoreD-UI/server"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2/altsrc"
)
var Command = &cli.Command{
Name: "server",
Usage: "run server",
Flags: []cli.Flag{
altsrc.NewStringFlag(&cli.StringFlag{
Name: "prefix",
Value: "/",
Usage: "web prefix",
}),
altsrc.NewStringFlag(&cli.StringFlag{
Name: "listen",
Value: "::",
Usage: "IP for listen at",
}),
altsrc.NewIntFlag(&cli.IntFlag{
Name: "port",
Value: 3000,
Usage: "Port for listen at",
}),
},
Action: runServer,
}
func runServer(c *cli.Context) error {
server, err := webserver.NewServer(c)
if err != nil {
return err
}
return server.Run()
}