-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathmain.go
61 lines (57 loc) · 1.46 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
// leetcode is a tool for managing leetcode source code.
package main
import (
"flag"
"fmt"
"github.com/openset/leetcode/internal/base"
"github.com/openset/leetcode/internal/build"
"github.com/openset/leetcode/internal/clean"
"github.com/openset/leetcode/internal/description"
"github.com/openset/leetcode/internal/help"
"github.com/openset/leetcode/internal/helper"
"github.com/openset/leetcode/internal/open"
"github.com/openset/leetcode/internal/page"
"github.com/openset/leetcode/internal/post"
"github.com/openset/leetcode/internal/question"
"github.com/openset/leetcode/internal/readme"
"github.com/openset/leetcode/internal/tag"
"github.com/openset/leetcode/internal/test"
"github.com/openset/leetcode/internal/update"
"github.com/openset/leetcode/internal/version"
)
func init() {
base.Commands = []*base.Command{
readme.CmdReadme,
page.CmdPage,
tag.CmdTag,
helper.CmdHelper,
question.CmdQuestion,
open.CmdOpen,
test.CmdTest,
description.CmdDescription,
update.CmdUpdate,
build.CmdBuild,
clean.CmdClean,
version.CmdVersion,
help.CmdHelp,
post.CmdPost,
}
}
func main() {
flag.Usage = base.Usage
flag.Parse()
if flag.NArg() < 1 {
flag.Usage()
return
}
args := flag.Args()
cmdName := args[0]
for _, cmd := range base.Commands {
if cmd.Name() == cmdName {
cmd.Run(cmd, args[1:])
return
}
}
fmt.Printf("%s %s: unknown command\n\n", base.CmdName, cmdName)
fmt.Printf("Run '%s help' for usage.\n", base.CmdName)
}