-
Notifications
You must be signed in to change notification settings - Fork 1
/
srctool.go
117 lines (111 loc) · 2.48 KB
/
srctool.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
// Copyright 2014-2015 The DevMine authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// srctool is a command line tool to manage source code parsers. It is able to
// download parsers from a web server, install them and run them. In short, it is a
// manager for source code parsers.
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
"github.com/DevMine/srctool/cmd"
"github.com/DevMine/srctool/log"
)
func main() {
app := cli.NewApp()
app.Name = "srctool"
app.Usage = "tool for parsing source code"
app.Version = "1.0.0"
app.Author = "The DevMine authors"
app.Email = "[email protected]"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "d",
Usage: "enable debug mode",
},
}
app.Commands = []cli.Command{
{
Name: "install",
ShortName: "i",
Usage: "install one or all language parser(s)",
Action: func(c *cli.Context) {
log.SetDebugMode(c.GlobalBool("d"))
cmd.Install(c)
},
},
{
Name: "delete",
ShortName: "d",
Usage: "delete one or all language parser(s)",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "dry",
Usage: "dry mode",
},
},
Action: func(c *cli.Context) {
log.SetDebugMode(c.GlobalBool("d"))
cmd.Delete(c)
},
},
{
Name: "update",
ShortName: "u",
Usage: "update one or all language parser(s)",
Action: func(c *cli.Context) {
log.SetDebugMode(c.GlobalBool("d"))
cmd.Update(c)
},
},
{
Name: "list",
ShortName: "l",
Usage: "list installed or available parsers",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "r",
Usage: "list remote parsers",
},
},
Action: func(c *cli.Context) {
log.SetDebugMode(c.GlobalBool("d"))
cmd.List(c)
},
},
{
Name: "parse",
ShortName: "p",
Usage: "parse a project",
Action: func(c *cli.Context) {
log.SetDebugMode(c.GlobalBool("d"))
cmd.Parse(c)
},
},
{
Name: "config",
ShortName: "c",
Usage: "create config file",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "server-url",
Usage: "get/set the download server URL",
},
},
Action: func(c *cli.Context) {
log.SetDebugMode(c.GlobalBool("d"))
cmd.Config(c)
},
},
{
Name: "version",
ShortName: "v",
Usage: "print program version",
Action: func(c *cli.Context) {
fmt.Printf("%s - v%s\n", app.Name, app.Version)
},
},
}
app.Run(os.Args)
}