main.go 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/version"
  11. )
  12. var cli struct {
  13. globals.Globals
  14. GenerateConfig config.Cmd `kong:"cmd,help='Generate the default configuration and exit.'"`
  15. GenerateRegistration registration.Cmd `kong:"cmd,help='Generate the registration file for synapse and exit.'"`
  16. Version version.Cmd `kong:"cmd,help='Display the version and exit.'"`
  17. }
  18. func main() {
  19. ctx := kong.Parse(
  20. &cli,
  21. kong.Name(consts.Name),
  22. kong.Description(consts.Description),
  23. kong.UsageOnError(),
  24. kong.ConfigureHelp(kong.HelpOptions{
  25. Compact: true,
  26. Summary: true,
  27. }),
  28. )
  29. err := ctx.Run(&cli.Globals)
  30. if err != nil {
  31. fmt.Fprintf(os.Stderr, "error: %s\n", err)
  32. os.Exit(1)
  33. }
  34. }