/
main.go
45 lines (38 loc) · 807 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
41
42
43
44
45
package main
import (
"flag"
"fmt"
"os"
"github.com/codegangsta/cli"
"github.com/golang/glog"
"tower.pro/renderer/command"
)
var version string
func main() {
defer glog.Flush()
flag.CommandLine.Parse([]string{"-logtostderr"})
app := cli.NewApp()
app.Name = "renderer"
app.Usage = "components compiler, renderer and command line tool with web interface"
app.Version = version
app.HideVersion = true
app.Commands = command.Commands
app.Flags = []cli.Flag{
cli.IntFlag{
Name: "v",
Usage: "verbosity (disables logs if < 0)",
EnvVar: "VERBOSITY",
},
}
app.Before = glogFlags
app.Run(os.Args)
}
func glogFlags(c *cli.Context) error {
v := c.Int("v")
if v < 0 {
flag.Set("logtostderr", "false")
} else if v > 0 {
flag.Set("v", fmt.Sprintf("%d", v))
}
return nil
}