campaigner/cmd/pull.go

32 lines
782 B
Go
Raw Normal View History

2020-04-30 07:13:31 +01:00
package cmd
import (
"github.com/spf13/cobra"
"git.ctrlz.es/mgdelacroix/campaigner/app"
)
func PullCmd() *cobra.Command {
return &cobra.Command{
Use: "pull",
Short: "Imports tickets from Jira",
Long: "Imports all tickets from a Jira epic issue. This command is only intended to use when the Jira tickets are already created and we want to use campaigner to import and manage them",
Args: cobra.NoArgs,
Run: withApp(pullCmdF),
}
}
func pullCmdF(a *app.App, cmd *cobra.Command, _ []string) {
tickets, err := a.GetTicketsFromJiraEpic()
if err != nil {
ErrorAndExit(cmd, err)
}
addedTickets := a.Campaign.AddTickets(tickets, false)
2020-04-30 07:13:31 +01:00
if err := a.Save(); err != nil {
ErrorAndExit(cmd, err)
}
cmd.Printf("%d tickets have been added\n", addedTickets)
2020-04-30 07:13:31 +01:00
}