main.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/alecthomas/kong"
  6. "gitlab.com/beeper/discord/config"
  7. "gitlab.com/beeper/discord/consts"
  8. "gitlab.com/beeper/discord/globals"
  9. "gitlab.com/beeper/discord/registration"
  10. "gitlab.com/beeper/discord/run"
  11. "gitlab.com/beeper/discord/version"
  12. )
  13. var cli struct {
  14. globals.Globals
  15. GenerateConfig config.Cmd `kong:"cmd,help='Generate the default configuration and exit.'"`
  16. GenerateRegistration registration.Cmd `kong:"cmd,help='Generate the registration file for synapse and exit.'"`
  17. Run run.Cmd `kong:"cmd,help='Run the bridge.',default='1'"`
  18. Version version.Cmd `kong:"cmd,help='Display the version and exit.'"`
  19. }
  20. func main() {
  21. ctx := kong.Parse(
  22. &cli,
  23. kong.Name(consts.Name),
  24. kong.Description(consts.Description),
  25. kong.UsageOnError(),
  26. kong.ConfigureHelp(kong.HelpOptions{
  27. Compact: true,
  28. Summary: true,
  29. }),
  30. )
  31. err := ctx.Run(&cli.Globals)
  32. if err != nil {
  33. fmt.Fprintf(os.Stderr, "error: %s\n", err)
  34. os.Exit(1)
  35. }
  36. }