forked from sequelize/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
135 lines (127 loc) · 3.41 KB
/
main.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import (
"fmt"
"log"
"os"
"runtime"
"github.com/codegangsta/cli"
"github.com/exercism/cli/api"
"github.com/exercism/cli/cmd"
)
const (
// Version is the current release of the command-line app.
// We try to follow Semantic Versioning (http://semver.org),
// but with the http://exercism.io app being a prototype, a
// lot of things get out of hand.
Version = "1.9.2"
descDebug = "Outputs useful debug information."
descConfigure = "Writes config values to a JSON file."
descDemo = "Fetches a demo problem for each language track on exercism.io."
descFetch = "Fetches your current problems on exercism.io, as well as the next unstarted problem in each language."
descRestore = "Restores completed and current problems on from exercism.io, along with your most recent iteration for each."
descSubmit = "Submits a new iteration to a problem on exercism.io."
descUnsubmit = "Deletes the most recently submitted iteration."
descTracks = "List the available language tracks"
descLongRestore = "Restore will pull the latest revisions of exercises that have already been submitted. It will *not* overwrite existing files. If you have made changes to a file and have not submitted it, and you're trying to restore the last submitted version, first move that file out of the way, then call restore."
descDownload = "Downloads and saves a specified submission into the local system"
descList = "Lists all available assignments for a given language"
)
func main() {
api.UserAgent = fmt.Sprintf("github.com/exercism/cli v%s (%s/%s)", Version, runtime.GOOS, runtime.GOARCH)
app := cli.NewApp()
app.Name = "exercism"
app.Usage = "A command line tool to interact with http://exercism.io"
app.Version = Version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "path to config file",
},
cli.BoolFlag{
Name: "debug, d",
Usage: "turn on verbose logging",
},
}
app.Commands = []cli.Command{
{
Name: "debug",
Usage: descDebug,
Action: cmd.Debug,
},
{
Name: "configure",
Usage: descConfigure,
Flags: []cli.Flag{
cli.StringFlag{
Name: "dir, d",
Usage: "path to exercises directory",
},
cli.StringFlag{
Name: "host, u",
Usage: "exercism api host",
},
cli.StringFlag{
Name: "key, k",
Usage: "exercism.io API key (see http://exercism.io/account)",
},
cli.StringFlag{
Name: "api, a",
Usage: "exercism xapi host",
},
},
Action: cmd.Configure,
},
{
Name: "demo",
ShortName: "d",
Usage: descDemo,
Action: cmd.Demo,
},
{
Name: "fetch",
ShortName: "f",
Usage: descFetch,
Action: cmd.Fetch,
},
{
Name: "restore",
ShortName: "r",
Usage: descRestore,
Description: descLongRestore,
Action: cmd.Restore,
},
{
Name: "submit",
ShortName: "s",
Usage: descSubmit,
Action: cmd.Submit,
},
{
Name: "unsubmit",
ShortName: "u",
Usage: descUnsubmit,
Action: cmd.Unsubmit,
},
{
Name: "tracks",
ShortName: "t",
Usage: descTracks,
Action: cmd.Tracks,
},
{
Name: "download",
ShortName: "dl",
Usage: descDownload,
Action: cmd.Download,
},
{
Name: "list",
ShortName: "li",
Usage: descList,
Action: cmd.List,
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}