Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextercism: implement download command #411

Closed
kytrinyx opened this issue Aug 4, 2017 · 3 comments
Closed

nextercism: implement download command #411

kytrinyx opened this issue Aug 4, 2017 · 3 comments
Assignees

Comments

@kytrinyx
Copy link
Member

kytrinyx commented Aug 4, 2017

To be merged into the nextercism branch in #410

Command name: download (alias d).
File: cmd/download.go.

Track is inferred

By default, you download by specifying the slug of the exercise. E.g.:

exercism download clock

The track can almost always be inferred based on context. Most people only work on one track. At other times we can determine the track based on the current location on the file system. If we are unable to identify a track, we will submit the request without one, and the API will respond with a list of possible tracks where this exercise is available to the user.

People can specify the --track flag (shortflag: t) to explicitly disambiguate.

Selective overwrite

If download an exercise and there are already files there, we will interactively ask whether or not the CLI should overwrite the file (each file individually). We'll show a diff to help make the decision.

If you run the download command with --force (or -f), it will automatically overwrite any existing files. There will also be a user setting so you can set force as default.

Downloading other people's solutions

You can download someone else's solution to something given a valid UUID, or the URL to their solution.

$ exercism download --uuid $UUID
$ exercism download --url $URL

This downloads it to a separate directory tree (TBD). E.g.

./$EXERCISM_DIR/users/:username/:track/:exercise

The separate directory tree is important, because we need to make it very easy for people to submit their exercises to version control, without accidentally storing (and exposing) other people's solutions.

We will be storing metadata about the solution in a hidden file locally, and the open command can be used with the path to an exercise (yours or someone else's) to make it easy to open it in the browser.

If you download multiple iterations of the same exercise, then they will be added to separate directories, with a serial, numeric suffix. This number is only for the user to disambiguate, and does not have anything to do with the actual iteration number on the site.

$EXERCISM_WORKSPACE/users/alice/go/clock
$EXERCISM_WORKSPACE/users/alice/go/clock-2
$EXERCISM_WORKSPACE/users/alice/go/clock-3

API Payload

{
      solution: {
        id: solution.uuid,
        url: solution_url,
        user: {
          handle: user_handle,
          is_requester: solution.user_id == requester.id
        },
        exercise: {
          id: solution.exercise.slug,
          instructions_url: instructions_url,
          track: {
            id: solution.exercise.track.slug,
            language: solution.exercise.track.title
          }
        },
        file_download_base_url: "https://api.exercism.io/v1/solutions/#{solution.uuid}/files/",
        files: files,
        iteration: iteration_hash
      }
    }

[maybe] Download all available

For the beta launch we will not be implementing a flag that lets you download all available exercises, but we will consider it for a future version.

If there is a huge need for downloading all exercises in a track (e.g. so that you can do Exercism exercises while on a long trip), then we will consider how to make that possible. It probably won't be built into the CLI, though.

[maybe] Download all solved

For the beta launch we will not be implementing behavior to let you download everything you've done on a track all at once, but we will consider it for a future version.

@kytrinyx
Copy link
Member Author

kytrinyx commented Aug 4, 2017

I have a kind of gross implementation of this locally that I'm going to clean up and submit.

@Tonkpils
Copy link
Contributor

@kytrinyx could this be closed since #452 was merged?

@kytrinyx
Copy link
Member Author

Yepp—there are a number of small fixes we need, but I'll triage them and open separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants