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

Add List command to display a list of available exercises #154

Merged
merged 1 commit into from
Jan 20, 2015

Conversation

lcowell
Copy link
Contributor

@lcowell lcowell commented Jan 18, 2015

WIP - I just realize that I need to handle a 500 response in the case that someone tries to list for a language like 'rub' or 'haskll'.

Closes #89

"github.com/exercism/cli/config"
)

const msgExplainFetch = "In order to fetch a specific assignment, call the fetch command with a specific assignment.\n\nexercism fetch ruby/matrix"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch command actually takes two arguments: exercism fetch ruby matrix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It actually worked for me to say exercism fetch ruby/matrix, but we should be telling people the right thing to do, not the thing that happens to work in this release.

@kytrinyx
Copy link
Member

It's cool to see progress again on this project! ✨ ❤️ ✨

@kytrinyx
Copy link
Member

I think the failing test was due to a stupid mistake I made on master.

@lcowell
Copy link
Contributor Author

lcowell commented Jan 19, 2015

One last thing I was wondering about is: should we be generating a better response when someone requests a language that doesn't exist ? eg http://x.exercism.io/tracks/rby will just give me a 500. That's ok, but I can't really know if I'm getting a 500 because of the language or because there's something going on with the server.

@kytrinyx
Copy link
Member

@@ -128,6 +128,31 @@ func Submit(url string, iter *Iteration) (*Submission, error) {
return ps.Submission, nil
}

// List available problems for a language
func List(language, host string) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way this function takes separate arguments as opposed to the composed url. Even providing host seems a bit off but until we have a Client struct for the api package this is fine. I think we should follow this same pattern for the other functions in this file. Any thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think what I like about this is that the caller of api.List doesn't need to know about how to compose a URL. AFAIK each of the api commands takes a url as an argument which means those URLs are probably being generated in each of the cmd funcs. I don't think that cmd package should know about URLs.

What do you think about making functions for generating URLs and putting them in the api package ? It kind of seems like the right place for them to me.

  func ListURL(language, host string) string {}
  func UnsubmitURL(host string) string {}
  func FetchURL(parts ...string) string {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed. Let's let the api worry about urls (functions or hard-coded), and the function arguments can be whatever information is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, that is probably an unrelated refactoring.

@kytrinyx
Copy link
Member

The API now returns a 404 for non-existent languages.

Do you want to update the PR with this before we merge? Once you're ready would you mind squashing the commits?

* lists available exercises for a given language and explains how to fetch them
* returns error for unknown languages
* Resolves issue exercism#89
* Fetches the track for a specific language using the /tracks/:language endopoint on the XAPI.
@lcowell
Copy link
Contributor Author

lcowell commented Jan 20, 2015

Handling 404s is in place. Commits squashed. Wahoo!

lcowell added a commit that referenced this pull request Jan 20, 2015
Add List command to display a list of available exercises
@lcowell lcowell merged commit b511ab9 into exercism:master Jan 20, 2015
@kytrinyx
Copy link
Member

Sweeeet!

lcowell added a commit to lcowell/cli that referenced this pull request Jan 25, 2015
Add List command to display a list of available exercises
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

Successfully merging this pull request may close these issues.

Display list of all the exercises
3 participants