-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathlist.go
More file actions
41 lines (34 loc) · 905 Bytes
/
list.go
File metadata and controls
41 lines (34 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cmd
import (
"fmt"
"log"
"github.com/codegangsta/cli"
"github.com/exercism/cli/api"
"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"
// List returns the full list of assignments for a given language
func List(ctx *cli.Context) {
c, err := config.New(ctx.GlobalString("config"))
if err != nil {
log.Fatal(err)
}
args := ctx.Args()
if len(args) != 1 {
msg := "Usage: exercism list LANGUAGE"
log.Fatal(msg)
}
language := args[0]
client := api.NewClient(c)
problems, err := client.List(language)
if err != nil {
if err == api.ErrUnknownLanguage {
log.Fatalf("The requested language '%s' is unknown", language)
}
log.Fatal(err)
}
for _, p := range problems {
fmt.Printf("%s\n", p)
}
fmt.Printf("\n%s\n\n", msgExplainFetch)
}