2024-04-03 09:05:12 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
webserver "reCoreD-UI/server"
|
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
2024-04-10 05:24:01 +00:00
|
|
|
"github.com/urfave/cli/v2/altsrc"
|
2024-04-03 09:05:12 +00:00
|
|
|
)
|
|
|
|
|
2024-04-10 05:24:01 +00:00
|
|
|
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",
|
2024-04-19 01:44:37 +00:00
|
|
|
Value: "::",
|
2024-04-10 05:24:01 +00:00
|
|
|
Usage: "IP for listen at",
|
|
|
|
}),
|
|
|
|
altsrc.NewIntFlag(&cli.IntFlag{
|
|
|
|
Name: "port",
|
2024-04-19 01:44:37 +00:00
|
|
|
Value: 3000,
|
2024-04-10 05:24:01 +00:00
|
|
|
Usage: "Port for listen at",
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
Action: runServer,
|
2024-04-03 09:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func runServer(c *cli.Context) error {
|
|
|
|
server, err := webserver.NewServer(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return server.Run()
|
|
|
|
}
|