package cmd import ( "fmt" "github.com/urfave/cli/v2" "go.jolheiser.com/beaver" "go.jolheiser.com/vanity/modules/router" "net/http" ) var Server = cli.Command{ Name: "server", Usage: "Start the vanity server", Flags: []cli.Flag{ &cli.StringFlag{ Name: "port", Aliases: []string{"p"}, Usage: "Port to run the vanity server on", Value: "3333", }, }, Action: doServer, } func doServer(ctx *cli.Context) error { beaver.Infof("Running vanity server at http://localhost:%s", ctx.String("port")) if err := http.ListenAndServe(fmt.Sprintf(":%s", ctx.String("port")), router.Init()); err != nil { return err } return nil }