main.go 593 B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "flag"
  4. "log"
  5. "github.com/ayn2op/discordo/cmd"
  6. "github.com/ayn2op/discordo/internal/constants"
  7. "github.com/zalando/go-keyring"
  8. )
  9. func main() {
  10. // Declare and parse all flags first
  11. token := flag.String("token", "", "The authentication token.")
  12. flag.Parse()
  13. // If no token was provided, look it up in the keyring
  14. if *token == "" {
  15. t, err := keyring.Get(constants.Name, "token")
  16. if err != nil {
  17. log.Println("Authentication token not found in keyring:", err)
  18. } else {
  19. *token = t
  20. }
  21. }
  22. if err := cmd.Run(*token); err != nil {
  23. log.Fatal(err)
  24. }
  25. }