Reviewed-on: phoenix/twilio_sender#4 Co-authored-by: kdeng00 <kundeng00@pm.me> Co-committed-by: kdeng00 <kundeng00@pm.me>
58 lines
1.1 KiB
Go
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)
|
|
}
|