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 )
}
2020-11-18 19:24:40 +01:00
addedTickets := a . Campaign . AddTickets ( tickets , false )
2020-04-30 07:13:31 +01:00
if err := a . Save ( ) ; err != nil {
ErrorAndExit ( cmd , err )
}
2020-11-18 19:24:40 +01:00
cmd . Printf ( "%d tickets have been added\n" , addedTickets )
2020-04-30 07:13:31 +01:00
}