main.go 569 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "flag"
  4. "log/slog"
  5. "github.com/ayn2op/discordo/cmd"
  6. "github.com/ayn2op/discordo/internal/config"
  7. "github.com/zalando/go-keyring"
  8. )
  9. func main() {
  10. token := flag.String("token", "", "authentication token")
  11. flag.Parse()
  12. // If no token was provided, look it up in the keyring
  13. if *token == "" {
  14. t, err := keyring.Get(config.Name, "token")
  15. if err != nil {
  16. slog.Info("failed to get token from keyring", "err", err)
  17. } else {
  18. *token = t
  19. }
  20. }
  21. if err := cmd.Run(*token); err != nil {
  22. slog.Error("failed to run", "err", err)
  23. }
  24. }