forked from vulsio/go-cpe-dictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (37 loc) · 1.03 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
package main
import (
"context"
"flag"
"fmt"
"os"
"strings"
"github.com/google/subcommands"
"github.com/remidinishanth/go-cpe-dictionary/commands"
)
// Name ... Name
const Name string = "go-cpe-dictionary"
// Version ... Version
var version = "0.2.2"
// Revision of Git
var revision string
func main() {
subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.FlagsCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(&commands.FetchNvdCmd{}, "fetchnvd")
var v = flag.Bool("v", false, "Show version")
if envArgs := os.Getenv("GO_CPE_DICTIONARY_ARGS"); 0 < len(envArgs) {
if err := flag.CommandLine.Parse(strings.Fields(envArgs)); err != nil {
fmt.Printf("Failed to parse env vars: %s. err: %s", envArgs, err)
os.Exit(int(subcommands.ExitFailure))
}
} else {
flag.Parse()
}
if *v {
fmt.Printf("%s %s %s\n", Name, version, revision)
os.Exit(int(subcommands.ExitSuccess))
}
ctx := context.Background()
os.Exit(int(subcommands.Execute(ctx)))
}