Files
sender/main.go
T
kdeng00 7b55ff5be2 go-lang (#1)
Reviewed-on: phoenix/twilio_sender#1
Co-authored-by: kdeng00 <kundeng94@gmail.com>
Co-committed-by: kdeng00 <kundeng94@gmail.com>
2024-08-24 21:20:30 +00:00

58 lines
1.1 KiB
Go

package main
import "fmt"
import "os"
import (
"git.kundeng.us/phoenix/twilio_sender/config"
"git.kundeng.us/phoenix/twilio_sender/models"
"git.kundeng.us/phoenix/twilio_sender/sender"
"git.kundeng.us/phoenix/twilio_sender/util"
)
func main() {
fmt.Println("twilio_sender")
myArgs := os.Args
argCount := len(myArgs)
fmt.Printf("Argument count: %v\n", argCount)
if argCount < 4 {
fmt.Println("Provide argument to config file and number file")
os.Exit(-1)
}
configPath, numberPath, messagePath := util.GetPaths(myArgs)
fmt.Printf("Config file path: %s\n", configPath)
cfg, _ := config.ParseConfig(configPath)
cfg.PrintConfig()
fmt.Println("Numbers file path:", numberPath)
numbers := util.ParseNumbers(numberPath)
if len(numbers) == 0 {
fmt.Println("No numbers to send")
os.Exit(-1)
}
models.PrintNumbers(numbers)
fmt.Println("")
fmt.Println("Message path:", messagePath)
message := util.ParseMessage(messagePath)
if message.IsEmpty() {
fmt.Println("No message to send")
os.Exit(-1)
}
message.Print()
sender.SendMessages(cfg, numbers, message, 5)
}