You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
858 B
Go

package cmd
import (
"cls-server/pkg/version"
_ "embed"
"encoding/json"
"fmt"
"github.com/urfave/cli/v2"
"math/rand"
"os"
"time"
)
var (
//go:embed banner.txt
usage string
)
func init() {
rand.Seed(time.Now().UnixNano())
cli.VersionPrinter = func(c *cli.Context) {
_ = json.NewEncoder(os.Stdout).Encode(map[string]string{
"package": version.Package,
"version": version.Version,
"revision": version.Revision,
"runtime": version.GoVersion,
})
}
}
func App() *cli.App {
app := cli.NewApp()
app.Name = "全景营销平台"
app.Version = version.Version
app.Usage = fmt.Sprintf(usage, version.Version)
app.Flags = []cli.Flag{
&cli.IntFlag{
Name: "port",
Aliases: []string{"p"},
Usage: "http端口",
Value: 8080,
},
}
app.Action = runServer
_, _ = fmt.Fprintln(os.Stdout, app.Usage)
return app
}