Add command now stores the tickets

This commit is contained in:
Miguel de la Cruz 2020-02-29 13:40:39 +01:00
parent 412d82269b
commit 44ab808223
3 changed files with 32 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"
"git.ctrlz.es/mgdelacroix/campaigner/campaign"
"git.ctrlz.es/mgdelacroix/campaigner/model"
)
@ -95,7 +96,15 @@ func addCmdF(cmd *cobra.Command, _ []string) {
ErrorAndExit(cmd, err)
}
for _, ticket := range tickets {
fmt.Printf("%+v\n", ticket)
cmp, err := campaign.Read()
if err != nil {
ErrorAndExit(cmd, err)
}
// ToDo: make this skip duplicates
cmp.Tickets = append(cmp.Tickets, tickets...)
if err := campaign.Save(cmp); err != nil {
ErrorAndExit(cmd, err)
}
}