Skip to content

Commit

Permalink
Extract print method
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsutherland committed Jan 2, 2019
1 parent 7510e3a commit 7242f77
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,7 @@ func runSubmit(cfg config.Config, flags *pflag.FlagSet, args []string) error {
return err
}

msg := `
Your solution has been submitted successfully.
%s
`
suffix := "View it at:\n\n "
if metadata.AutoApprove && 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", metadata.URL)
ctx.printResult(metadata)
return nil
}

Expand Down Expand Up @@ -342,6 +332,20 @@ func (ctx *submitContext) submitRequest(id string, docs []workspace.Document) er
return nil
}

func (ctx *submitContext) printResult(metadata *workspace.ExerciseMetadata) {
msg := `
Your solution has been submitted successfully.
%s
`
suffix := "View it at:\n\n "
if metadata.AutoApprove && 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", metadata.URL)
}

func init() {
RootCmd.AddCommand(submitCmd)
}
Expand Down

0 comments on commit 7242f77

Please sign in to comment.