main.go 937 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "os"
  4. "fmt"
  5. "github.com/pborman/getopt"
  6. api "devel.mephi.ru/dyokunev/go-ssms.su/ssmsSuApi"
  7. )
  8. func main() {
  9. var err error
  10. var login string
  11. var password string
  12. var recipient string
  13. var message string
  14. var senderName string
  15. getopt.StringVar(&login, 'l', "login" )
  16. getopt.StringVar(&password, 'p', "password" )
  17. getopt.StringVar(&recipient, 't', "recipient" )
  18. getopt.StringVar(&message, 'm', "message" )
  19. getopt.StringVar(&senderName, 'f', "sender-name" )
  20. getopt.Parse()
  21. if (getopt.NArgs() > 0) {
  22. getopt.Usage()
  23. os.Exit(-2)
  24. }
  25. if (login == "" || password == "" || recipient == "" || message == "") {
  26. getopt.Usage()
  27. os.Exit(-2)
  28. }
  29. err, r := api.SendSms(login, password, recipient, message, senderName)
  30. if (err != nil) {
  31. fmt.Printf("Cannot send the SMS: %v\n", err.Error())
  32. os.Exit(-1)
  33. }
  34. fmt.Printf("Error: %v; Response: %v\n", err, r);
  35. os.Exit(0);
  36. }