This repository has been archived by the owner on Mar 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
69 lines (59 loc) · 1.49 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
package main
import (
"os"
"github.com/Sirupsen/logrus"
"github.com/rocket-internet-berlin/RocketLabsRubberDoc/command"
"github.com/urfave/cli"
)
func main() {
cmd := &command.GenerateCommand{}
logger := logrus.New()
app := cli.NewApp()
app.Name = "RubberDoc"
app.Version = "v0.1-alpha-2"
app.Description = "A documentation generator for RAML and Blueprint."
app.Usage = ""
var debugLogging bool
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug, d",
Usage: "Enable debug logging",
Destination: &debugLogging,
},
}
app.Before = func(c *cli.Context) error {
logger.Formatter = &logrus.TextFormatter{FullTimestamp: true}
if c.GlobalBool("debug") {
logger.Level = logrus.DebugLevel
logger.Debug("Debug logging enabled")
logger.Debug(app.Name, "-", app.Version)
}
return nil
}
app.Commands = []cli.Command{
{
Name: "generate",
Usage: "This command receives a configuration file and a specification file written in RAML or Blueprint.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "spec",
Value: "",
Usage: "Specify the Specification's file location.",
Destination: &cmd.SpecFile,
},
cli.StringFlag{
Name: "config",
Value: "",
Usage: "Specify the configuration's file location.",
Destination: &cmd.ConfigFile,
},
},
Action: func(c *cli.Context) {
if err := cmd.Execute(); err != nil {
logger.Error(err)
}
},
},
}
app.Run(os.Args)
}