-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.go
69 lines (54 loc) · 1.3 KB
/
export.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package issue
import (
"errors"
"fmt"
"github.com/andygrunwald/go-jira"
"github.com/briandowns/spinner"
"github.com/locona/jira/pkg/issue"
"github.com/locona/jira/pkg/prompt"
"github.com/spf13/cobra"
)
func NewCommandExport() *cobra.Command {
cmd := &cobra.Command{
Use: "export",
RunE: func(cmd *cobra.Command, args []string) error {
return Export()
},
}
return cmd
}
type ExportCommand struct {
Issue *jira.Issue
Transition *jira.Transition
}
func (cmd *ExportCommand) Request(s *spinner.Spinner) error {
label := issue.Label(*cmd.Issue)
suffixFormat := "%v : Export To `%v`"
suffixMsg := fmt.Sprintf(suffixFormat, label, cmd.Transition.Name)
var suf = make([]byte, 100)
copy(suf, suffixMsg)
s.Suffix = string(suf)
s.FinalMSG = fmt.Sprintf("%v %v \n", prompt.IconClear, suffixMsg)
err := issue.ChangeTransition(cmd.Issue.Key, cmd.Transition.ID)
if err != nil {
return err
}
return nil
}
func (cmd *ExportCommand) Response() error {
return nil
}
func Export() error {
selectedIssueSlice, err := multiSelectIssue("Select the issue status you whose status you want to change.")
if err != nil {
return err
}
if len(selectedIssueSlice) < 1 {
return errors.New("Required Select Issue")
}
err = issue.Export(selectedIssueSlice)
if err != nil {
return err
}
return nil
}