Add project as part of the campaign

This commit is contained in:
Miguel de la Cruz 2020-03-04 23:59:23 +01:00
parent 79caaae287
commit 788146e1fa
2 changed files with 5 additions and 1 deletions

View file

@ -15,6 +15,8 @@ func InitCmd() *cobra.Command {
Run: initCmdF, Run: initCmdF,
} }
cmd.Flags().StringP("project", "p", "", "the jira project key to associate the tickets with")
_ = cmd.MarkFlagRequired("project")
cmd.Flags().StringP("epic", "e", "", "the epic id to associate this campaign with") cmd.Flags().StringP("epic", "e", "", "the epic id to associate this campaign with")
_ = cmd.MarkFlagRequired("epic") _ = cmd.MarkFlagRequired("epic")
cmd.Flags().StringP("summary", "s", "", "the summary of the tickets. Can contain the variables {{.Filename}}, {{.LineNo}} and {{.Text}}") cmd.Flags().StringP("summary", "s", "", "the summary of the tickets. Can contain the variables {{.Filename}}, {{.LineNo}} and {{.Text}}")
@ -24,9 +26,10 @@ func InitCmd() *cobra.Command {
} }
func initCmdF(cmd *cobra.Command, _ []string) { func initCmdF(cmd *cobra.Command, _ []string) {
project, _ := cmd.Flags().GetString("project")
epic, _ := cmd.Flags().GetString("epic") epic, _ := cmd.Flags().GetString("epic")
summary, _ := cmd.Flags().GetString("summary") summary, _ := cmd.Flags().GetString("summary")
if err := campaign.Save(&model.Campaign{Epic: epic, Summary: summary}); err != nil { if err := campaign.Save(&model.Campaign{Project: project, Epic: epic, Summary: summary}); err != nil {
ErrorAndExit(cmd, err) ErrorAndExit(cmd, err)
} }
} }

View file

@ -1,6 +1,7 @@
package model package model
type Campaign struct { type Campaign struct {
Project string `json:"project"`
Epic string `json:"epic"` Epic string `json:"epic"`
Summary string `json:"summary"` Summary string `json:"summary"`
Tickets []*Ticket `json:"tickets,omitempty"` Tickets []*Ticket `json:"tickets,omitempty"`