-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (41 loc) · 985 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
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"os"
"github.com/moby/moby/pkg/reexec"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"aproton.tech/container/container"
"aproton.tech/container/image"
"aproton.tech/container/utils"
)
func init() {
logrus.SetFormatter(&utils.LogFormatter{})
logrus.SetReportCaller(true)
reexec.Register(container.ReExecRunCommand, func() {
utils.SetSubProcessFlag()
if err := container.Run(os.Args[1], os.Args[2]); err != nil {
utils.Assert(err)
}
logrus.Infof("run finished")
})
}
func main() {
if reexec.Init() {
os.Exit(0)
}
rootCmd := &cobra.Command{
Use: "container",
Long: `container`,
Version: "1.0",
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
}
for _, cmd := range container.ContainerCommands() {
rootCmd.AddCommand(cmd)
}
rootCmd.AddCommand(image.ImageCommand())
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}