[feat] add rm option

This commit is contained in:
jay
2022-07-19 16:42:05 +08:00
parent 1988ed6762
commit 7a23303a1b
2 changed files with 19 additions and 2 deletions
+3 -1
View File
@@ -16,6 +16,7 @@ func main() {
var imageName string
var tarName string
var doPull bool
var rm bool
rootCmd = &cobra.Command{
Use: "docker-save",
@@ -27,7 +28,7 @@ func main() {
}
ctx := context.Background()
if err := docker.SaveImageTar(ctx, imageName, outputPath, tarName, doPull); err != nil {
if err := docker.SaveImageTar(ctx, imageName, outputPath, tarName, doPull, rm); err != nil {
log.Fatal(err)
}
},
@@ -36,6 +37,7 @@ func main() {
rootCmd.Flags().StringVarP(&imageName, "image", "i", "", "image name")
rootCmd.Flags().StringVarP(&tarName, "name", "n", "", "tar name")
rootCmd.Flags().BoolVarP(&doPull, "pull", "p", false, "pull image")
rootCmd.Flags().BoolVarP(&rm, "rm", "", false, "delete image after save")
rootCmd.MarkFlagRequired("image")
rootCmd.MarkFlagRequired("output")