go-lang (#1)
Reviewed-on: phoenix/twilio_sender#1 Co-authored-by: kdeng00 <kundeng94@gmail.com> Co-committed-by: kdeng00 <kundeng94@gmail.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user