2020-02-21 04:39:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-09-10 17:27:46 +00:00
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
|
2020-09-12 01:38:18 +00:00
|
|
|
"go.jolheiser.com/vanity/api"
|
2020-09-10 17:27:46 +00:00
|
|
|
"go.jolheiser.com/vanity/flags"
|
|
|
|
"go.jolheiser.com/vanity/router"
|
|
|
|
|
2020-02-21 04:39:03 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"go.jolheiser.com/beaver"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "vanity"
|
|
|
|
app.Usage = "Vanity Go Imports"
|
2020-09-12 01:38:18 +00:00
|
|
|
app.Version = api.Version
|
2020-09-10 17:27:46 +00:00
|
|
|
app.Action = doAction
|
|
|
|
app.Flags = flags.Flags
|
|
|
|
app.Before = flags.Before
|
|
|
|
|
|
|
|
beaver.Console.Format = beaver.FormatOptions{
|
|
|
|
TimePrefix: true,
|
|
|
|
StackPrefix: true,
|
|
|
|
StackLimit: 15,
|
|
|
|
LevelPrefix: true,
|
|
|
|
LevelColor: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
beaver.Fatal(err)
|
2020-02-21 04:39:03 +00:00
|
|
|
}
|
2020-09-10 17:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func doAction(ctx *cli.Context) error {
|
|
|
|
if err := http.ListenAndServe(fmt.Sprintf(":%s", ctx.String("port")), router.Init()); err != nil {
|
|
|
|
return err
|
2020-02-21 04:39:03 +00:00
|
|
|
}
|
2020-09-10 17:27:46 +00:00
|
|
|
return nil
|
2020-02-21 04:39:03 +00:00
|
|
|
}
|