Skip to content

Commit

Permalink
Add console messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoutsilis committed Jan 18, 2024
1 parent c18462e commit fa8701c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ func checkIsJson(path string) bool {
}

func generateSecretSantaMatches(data []Data) []MatchPair {
fmt.Println("Generating Secret Santa Matches, HO HO HO...")
shuffledData := make([]Data, len(data))
copy(shuffledData, data)
rand.Shuffle(len(shuffledData), func(i, j int) {
shuffledData[i], shuffledData[j] = shuffledData[j], shuffledData[i]
})

fmt.Println("Matches generated, but you can't see them, HO HO HO...")
return circlularMatchingAlgorithm(shuffledData)
}

Expand Down Expand Up @@ -93,7 +94,7 @@ func loadEmailTemplate(filePath string) (*template.Template, error) {
}

func generateEmailMessages(matches []MatchPair, tmpl *template.Template) ([]*gomail.Message, error) {

fmt.Println("Preparing the emails for those amazing people, HO HO HO...")
emailMessages := make([]*gomail.Message, 0, len(matches))
for _, match := range matches {
emailBody, err := populateEmailBody(match, tmpl)
Expand All @@ -107,6 +108,7 @@ func generateEmailMessages(matches []MatchPair, tmpl *template.Template) ([]*gom
}

func sendEmails(emailMessages ...*gomail.Message) error {
fmt.Println("Sending the emails, HO HO HO...")
host := os.Getenv("EMAIL_HOST")
strPort := os.Getenv("EMAIL_PORT")
user := os.Getenv("EMAIL_USER")
Expand Down Expand Up @@ -198,7 +200,7 @@ var rootCmd = &cobra.Command{
if err != nil {
return errors.Wrap(err, "error sending emails")
}

fmt.Println("Happy gift hunting, and happy holidays!")
return nil
},
}
Expand Down

0 comments on commit fa8701c

Please sign in to comment.