-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (37 loc) · 960 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
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/hashicorp/packer/packer/plugin"
"github.com/kwilczynski/packer-provisioner-itamae-local/itamae"
)
func main() {
//
if len(os.Args) > 1 {
switch os.Args[1] {
case "-h", "-help", "--help", "help":
fmt.Printf(
"Usage: %s [--version] [--help] <COMMAND>\n\n"+
"Available commands are:\n"+
" version Print the version and exit.\n"+
" help Show this help screen.\n\n",
filepath.Base(os.Args[0]))
case "version":
version := fmt.Sprintf("Provisioner Itamae v%s", itamaelocal.Version)
if itamaelocal.Revision != "" {
version += fmt.Sprintf(" (%s)", itamaelocal.Revision)
}
fmt.Println(version)
case "-v", "-version", "--version":
fmt.Printf("%s\n", itamaelocal.Version)
}
os.Exit(0)
}
server, err := plugin.Server()
if err != nil {
panic(err)
}
server.RegisterProvisioner(&itamaelocal.Provisioner{})
server.Serve()
}