@@ -23,7 +23,7 @@ const (
2323 CancelAction
2424)
2525
26- func confirm () (Action , error ) {
26+ var ConfirmSubmission = func () (Action , error ) {
2727 confirmAnswers := struct {
2828 Confirmation int
2929 }{}
@@ -49,7 +49,7 @@ func confirm() (Action, error) {
4949 return Action (confirmAnswers .Confirmation ), nil
5050}
5151
52- func selectTemplate (templatePaths []string ) (string , error ) {
52+ var SelectTemplate = func (templatePaths []string ) (string , error ) {
5353 templateResponse := struct {
5454 Index int
5555 }{}
@@ -77,17 +77,26 @@ func selectTemplate(templatePaths []string) (string, error) {
7777 return string (templateContents ), nil
7878}
7979
80- func titleBodySurvey (cmd * cobra.Command , providedTitle string , providedBody string , templatePaths []string ) (* titleBody , error ) {
80+ var SurveyAsk = func (qs []* survey.Question , response interface {}, opts ... survey.AskOpt ) error {
81+ return survey .Ask (qs , response , opts ... )
82+ }
83+
84+ func titleBodySurvey (cmd * cobra.Command , providedTitle , providedBody string , defs defaults , templatePaths []string ) (* titleBody , error ) {
8185 var inProgress titleBody
86+ inProgress .Title = defs .Title
8287 templateContents := ""
8388
84- if providedBody == "" && len (templatePaths ) > 0 {
85- var err error
86- templateContents , err = selectTemplate (templatePaths )
87- if err != nil {
88- return nil , err
89+ if providedBody == "" {
90+ if len (templatePaths ) > 0 {
91+ var err error
92+ templateContents , err = SelectTemplate (templatePaths )
93+ if err != nil {
94+ return nil , err
95+ }
96+ inProgress .Body = templateContents
97+ } else {
98+ inProgress .Body = defs .Body
8999 }
90- inProgress .Body = templateContents
91100 }
92101
93102 titleQuestion := & survey.Question {
@@ -127,7 +136,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle string, providedBody stri
127136 inProgress .Body = templateContents
128137 }
129138
130- confirmA , err := confirm ()
139+ confirmA , err := ConfirmSubmission ()
131140 if err != nil {
132141 return nil , fmt .Errorf ("unable to confirm: %w" , err )
133142 }
0 commit comments