Skip to content

Commit

Permalink
Merge pull request exercism#816 from exercism/enhance-download-payload
Browse files Browse the repository at this point in the history
Enhance downloadPayload with helper to return exercise metadata
  • Loading branch information
Katrina Owen authored Feb 26, 2019
2 parents 596419e + c6a395d commit a88b3f1
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,7 @@ func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error {
}
}

metadata := workspace.ExerciseMetadata{
AutoApprove: payload.Solution.Exercise.AutoApprove,
Track: payload.Solution.Exercise.Track.ID,
Team: payload.Solution.Team.Slug,
ExerciseSlug: payload.Solution.Exercise.ID,
ID: payload.Solution.ID,
URL: payload.Solution.URL,
Handle: payload.Solution.User.Handle,
IsRequester: payload.Solution.User.IsRequester,
}
metadata := payload.metadata()

root := usrCfg.GetString("workspace")
if metadata.Team != "" {
Expand Down Expand Up @@ -263,6 +254,19 @@ type downloadPayload struct {
} `json:"error,omitempty"`
}

func (dp downloadPayload) metadata() workspace.ExerciseMetadata {
return workspace.ExerciseMetadata{
AutoApprove: dp.Solution.Exercise.AutoApprove,
Track: dp.Solution.Exercise.Track.ID,
Team: dp.Solution.Team.Slug,
ExerciseSlug: dp.Solution.Exercise.ID,
ID: dp.Solution.ID,
URL: dp.Solution.URL,
Handle: dp.Solution.User.Handle,
IsRequester: dp.Solution.User.IsRequester,
}
}

func setupDownloadFlags(flags *pflag.FlagSet) {
flags.StringP("uuid", "u", "", "the solution UUID")
flags.StringP("track", "t", "", "the track ID")
Expand Down

0 comments on commit a88b3f1

Please sign in to comment.