From 788146e1fae2b26a8d41aa69ee08a5f5505c77fa Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Wed, 4 Mar 2020 23:59:23 +0100 Subject: [PATCH] Add project as part of the campaign --- cmd/init.go | 5 ++++- model/campaign.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/init.go b/cmd/init.go index 07d80a5..9270d2d 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -15,6 +15,8 @@ func InitCmd() *cobra.Command { 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.MarkFlagRequired("epic") 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) { + project, _ := cmd.Flags().GetString("project") epic, _ := cmd.Flags().GetString("epic") 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) } } diff --git a/model/campaign.go b/model/campaign.go index 27534ab..39ed165 100644 --- a/model/campaign.go +++ b/model/campaign.go @@ -1,6 +1,7 @@ package model type Campaign struct { + Project string `json:"project"` Epic string `json:"epic"` Summary string `json:"summary"` Tickets []*Ticket `json:"tickets,omitempty"`