-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Conversation
"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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
It's cool to see progress again on this project! ✨ ❤️ ✨ |
I think the failing test was due to a stupid mistake I made on master. |
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 |
That should return a 404, not a 500. |
@@ -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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 {}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
Handling 404s is in place. Commits squashed. Wahoo! |
Add List command to display a list of available exercises
Sweeeet! |
Add List command to display a list of available exercises
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