-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
73 lines (63 loc) · 1.68 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
70
71
72
73
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/urfave/cli/v2"
)
var (
// Version describes the version of the current build.
Version = "dev"
// Commit describes the commit of the current build.
Commit = "none"
// Date describes the date of the current build.
Date = "unknown"
// Release describes the stage of the current build, eg; development, production, etc...
Stage = "unknown"
)
func main() {
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("Version: %s, Stage: %s, Commit: %s, Date: %s\n", Version, Stage, Commit, Date)
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version",
Usage: "print only the version",
Aliases: []string{"v"},
}
app := &cli.App{
Name: "gadget",
Usage: "inspect your code via a small layer of abstraction over Go's AST package",
Version: Version,
Compiled: time.Now(),
Authors: []*cli.Author{{
Name: "Wilhelm Murdoch",
Email: "wilhelm@devilmayco.de",
}},
Copyright: "(c) 2022 Wilhelm Codes ( https://wilhelm.codes )",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "source",
Usage: "path to the target go source file, or directory containing go source files.",
Value: ".",
Aliases: []string{"s"},
},
&cli.StringFlag{
Name: "format",
Usage: "the output format of the results as json, template or debug.",
Value: "json",
Aliases: []string{"f"},
},
&cli.StringFlag{
Name: "template",
Usage: "if the template format is selected, this is the path to the template file to use.",
Value: "README.tpl",
Aliases: []string{"t"},
},
},
Action: actionRootHandler,
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}