Closes #6 Reviewed-on: #10 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.kundeng.us/phoenix/sender/config"
|
|
"git.kundeng.us/phoenix/sender/messaging"
|
|
"git.kundeng.us/phoenix/sender/models"
|
|
"git.kundeng.us/phoenix/sender/util"
|
|
"git.kundeng.us/phoenix/sender/version"
|
|
)
|
|
|
|
func main() {
|
|
myArgs := os.Args
|
|
argCount := len(myArgs)
|
|
|
|
if config.IsVersionFlagPresent() {
|
|
fmt.Println(config.App_Name)
|
|
fmt.Println(version.String())
|
|
return
|
|
} else if argCount < 4 {
|
|
fmt.Printf("Argument count: %v\n", argCount)
|
|
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()
|
|
|
|
messaging.SendMessages(cfg, numbers, message, 5)
|
|
}
|