12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package main
- import (
- "fmt"
- "git.linuxforward.com/byom/byom-core/app"
- "git.linuxforward.com/byom/byom-core/config"
- "github.com/alecthomas/kong"
- )
- var (
- version = "0.0.1-dev"
- commit = "none"
- date = "unknown"
- )
- var cli struct {
- Serve ServeCmd `cmd:"serve" help:"Run the server"`
- Version VersionCmd `cmd:"version" help:"Print version information"`
- }
- type ServeCmd struct {
- Config string `type:"path" help:"Path to the configuration file." default:"config.yaml"`
- }
- func (c *ServeCmd) Run() error {
- cnf, err := config.ReadConfig(c.Config)
- if err != nil {
- return err
- }
- app, err := app.NewApp(cnf)
- if err != nil {
- return err
- }
- return app.Run()
- }
- type VersionCmd struct{}
- func (c *VersionCmd) Run() error {
- fmt.Printf("byom-core %s, commit %s, built at %s", version, commit, date)
- return nil
- }
- func main() {
- ctx := kong.Parse(&cli)
- err := ctx.Run()
- ctx.FatalIfErrorf(err)
- }
|