-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (36 loc) · 926 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
/*
Copyright © William Wang <[email protected]>
*/
package main
import (
"docker-save/command/commands"
"docker-save/command/image"
"docker-save/docker"
"fmt"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
)
func newDockerSaveCommand(dockerCli *docker.DockerCli) *cobra.Command {
rootCmd := image.NewSaveCommand(dockerCli)
rootCmd.SilenceUsage = true
rootCmd.SilenceErrors = true
rootCmd.TraverseChildren = true
rootCmd.SetIn(dockerCli.In())
rootCmd.SetOut(dockerCli.Out())
rootCmd.SetErr(dockerCli.Err())
commands.AddCommands(rootCmd, dockerCli)
return rootCmd
}
func runDockerSave(dockerCli *docker.DockerCli) error {
rootCmd := newDockerSaveCommand(dockerCli)
return rootCmd.Execute()
}
func main() {
dockerCli := docker.NewDockerCli()
logrus.SetOutput(dockerCli.Err())
if err := runDockerSave(dockerCli); err != nil {
fmt.Fprintln(dockerCli.Err(), err)
os.Exit(1)
}
}