Skip to content

Commit

Permalink
Move printResult to submitCmdContext
Browse files Browse the repository at this point in the history
printing really depends on the submitCmd rather than the submission
itself
  • Loading branch information
jdsutherland committed Jan 2, 2019
1 parent d0afa9f commit 9dd0499
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ func (s *submitCmdContext) _documents(filepaths []string, exercise workspace.Exe
return docs, nil
}

func (s *submitCmdContext) printResult() {
msg := `
Your solution has been submitted successfully.
%s
`
suffix := "View it at:\n\n "
if s.metadata.AutoApprove && s.metadata.Team == "" {
suffix = "You can complete the exercise and unlock the next core exercise at:\n"
}
fmt.Fprintf(Err, msg, suffix)
fmt.Fprintf(Out, " %s\n\n", s.metadata.URL)
}

type submission struct {
documents []workspace.Document
metadata *workspace.ExerciseMetadata
Expand Down Expand Up @@ -344,20 +358,6 @@ func (s submission) submit(usrCfg *viper.Viper) error {
return nil
}

func (s submission) printResult() {
msg := `
Your solution has been submitted successfully.
%s
`
suffix := "View it at:\n\n "
if s.metadata.AutoApprove && s.metadata.Team == "" {
suffix = "You can complete the exercise and unlock the next core exercise at:\n"
}
fmt.Fprintf(Err, msg, suffix)
fmt.Fprintf(Out, " %s\n\n", s.metadata.URL)
}

func (s submission) validate() error {
if s.metadata.ID == "" {
return errors.New("id is empty")
Expand Down

0 comments on commit 9dd0499

Please sign in to comment.