Skip to content

Commit a88b3f1

Browse files
author
Katrina Owen
authored
Merge pull request #816 from exercism/enhance-download-payload
Enhance downloadPayload with helper to return exercise metadata
2 parents 596419e + c6a395d commit a88b3f1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

cmd/download.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,7 @@ func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error {
129129
}
130130
}
131131

132-
metadata := workspace.ExerciseMetadata{
133-
AutoApprove: payload.Solution.Exercise.AutoApprove,
134-
Track: payload.Solution.Exercise.Track.ID,
135-
Team: payload.Solution.Team.Slug,
136-
ExerciseSlug: payload.Solution.Exercise.ID,
137-
ID: payload.Solution.ID,
138-
URL: payload.Solution.URL,
139-
Handle: payload.Solution.User.Handle,
140-
IsRequester: payload.Solution.User.IsRequester,
141-
}
132+
metadata := payload.metadata()
142133

143134
root := usrCfg.GetString("workspace")
144135
if metadata.Team != "" {
@@ -263,6 +254,19 @@ type downloadPayload struct {
263254
} `json:"error,omitempty"`
264255
}
265256

257+
func (dp downloadPayload) metadata() workspace.ExerciseMetadata {
258+
return workspace.ExerciseMetadata{
259+
AutoApprove: dp.Solution.Exercise.AutoApprove,
260+
Track: dp.Solution.Exercise.Track.ID,
261+
Team: dp.Solution.Team.Slug,
262+
ExerciseSlug: dp.Solution.Exercise.ID,
263+
ID: dp.Solution.ID,
264+
URL: dp.Solution.URL,
265+
Handle: dp.Solution.User.Handle,
266+
IsRequester: dp.Solution.User.IsRequester,
267+
}
268+
}
269+
266270
func setupDownloadFlags(flags *pflag.FlagSet) {
267271
flags.StringP("uuid", "u", "", "the solution UUID")
268272
flags.StringP("track", "t", "", "the track ID")

0 commit comments

Comments
 (0)