-
Notifications
You must be signed in to change notification settings - Fork 44
/
main.go
59 lines (50 loc) · 1.48 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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package main
import (
_ "embed"
"log"
"os"
"github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc/internal/fix"
mapstructure_to_hcl2 "github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc/internal/mapstructure-to-hcl2"
"github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc/internal/plugincheck"
"github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc/internal/renderdocs"
struct_markdown "github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc/internal/struct-markdown"
"github.com/hashicorp/packer-plugin-sdk/version"
"github.com/mitchellh/cli"
)
var (
app = "packer-sdc"
//go:embed README.md
readme string
)
func main() {
c := cli.NewCLI(app, version.SDKVersion.String())
c.Args = os.Args[1:]
c.HelpFunc = func(m map[string]cli.CommandFactory) string {
str := cli.BasicHelpFunc(app)(m)
return str + "\n" + readme
}
c.Commands = map[string]cli.CommandFactory{
"struct-markdown": func() (cli.Command, error) {
return &struct_markdown.Command{}, nil
},
"mapstructure-to-hcl2": func() (cli.Command, error) {
return &mapstructure_to_hcl2.Command{}, nil
},
"renderdocs": func() (cli.Command, error) {
return &renderdocs.Command{}, nil
},
"plugin-check": func() (cli.Command, error) {
return &plugincheck.Command{}, nil
},
"fix": func() (cli.Command, error) {
return &fix.Command{}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
log.Println(err)
}
os.Exit(exitStatus)
}