forked from src-d/gitbase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 788 Bytes
/
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
package main
import (
"fmt"
"os"
"github.com/jessevdk/go-flags"
)
const (
name = "gitquery"
)
func main() {
parser := flags.NewNamedParser(name, flags.Default)
parser.AddCommand("query", "Execute a SQL query a repository.", "", &CmdQuery{})
parser.AddCommand("shell", "Start an interactive session.", "", &CmdShell{})
parser.AddCommand("version", "Show the version information.", "", &CmdVersion{})
_, err := parser.Parse()
if err != nil {
if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrCommandRequired {
parser.WriteHelp(os.Stdout)
}
os.Exit(1)
}
}
type cmd struct {
Verbose bool `short:"v" description:"Activates the verbose mode"`
}
func (c *cmd) print(format string, a ...interface{}) {
if !c.Verbose {
return
}
fmt.Printf(format, a...)
}